
package{

	import flash.display.*;
	import flash.events.*;

	[SWF(width="640",height="480")]
	
	public class MonkeyGame extends Sprite{
	
		public function MonkeyGame(){
		
			addEventListener( Event.ADDED_TO_STAGE,OnAddedToStage );
		}
		
		private function OnAddedToStage( e:Event ):void{
		
			BBMonkeyGame.Main( this );
		}
	}
}

final class Config{
//${CONFIG_BEGIN}
internal static var BINARY_FILES:String="*.bin|*.dat"
internal static var BRL_DATABUFFER_IMPLEMENTED:String="1"
internal static var BRL_GAMETARGET_IMPLEMENTED:String="1"
internal static var BRL_THREAD_IMPLEMENTED:String="1"
internal static var CONFIG:String="debug"
internal static var FLASH_RENDER_WHILE_SUSPENDED:String="0"
internal static var HOST:String="winnt"
internal static var IMAGE_FILES:String="*.png|*.jpg"
internal static var LANG:String="as"
internal static var MINIB3D_DEBUG_MODEL:String="0"
internal static var MINIB3D_DRIVER:String=""
internal static var MOJO_AUTO_SUSPEND_ENABLED:String="1"
internal static var MOJO_DRIVER_IMPLEMENTED:String="1"
internal static var MOJO_IMAGE_FILTERING_ENABLED:String="1"
internal static var MUSIC_FILES:String="*.mp3"
internal static var SAFEMODE:String="0"
internal static var SOUND_FILES:String="*.mp3"
internal static var TARGET:String="flash"
internal static var TEXT_FILES:String="*.txt|*.xml|*.xrf|*.xaf|*.xmf|*.xaf|*.xsf"
//${CONFIG_END}
}

final class Assets{
//${ASSETS_BEGIN}
[Embed(source="data/imvu/master.xsf",mimeType="application/octet-stream")]
public static var _4imvu6master3xsf:Class;
[Embed(source="data/imvu/mbody.xmf",mimeType="application/octet-stream")]
public static var _4imvu5mbody3xmf:Class;
[Embed(source="data/imvu/mhead.xmf",mimeType="application/octet-stream")]
public static var _4imvu5mhead3xmf:Class;
[Embed(source="data/paladin/paladin.xmf",mimeType="application/octet-stream")]
public static var _7paladin7paladin3xmf:Class;
[Embed(source="data/paladin/run.xaf",mimeType="application/octet-stream")]
public static var _7paladin3run3xaf:Class;
[Embed(source="data/paladin/skele.xsf",mimeType="application/octet-stream")]
public static var _7paladin5skele3xsf:Class;
[Embed(source="data/paladin/skeleb.xsf",mimeType="application/octet-stream")]
public static var _7paladin6skeleb3xsf:Class;
[Embed(source="data/paladin/test.xsf",mimeType="application/octet-stream")]
public static var _7paladin4test3xsf:Class;
[Embed(source="data/paladin/testp.xmf",mimeType="application/octet-stream")]
public static var _7paladin5testp3xmf:Class;
[Embed(source="data/paladin/walk.xaf",mimeType="application/octet-stream")]
public static var _7paladin4walk3xaf:Class;
[Embed(source="data/mojo_font.png")]
public static var _9mojo_font3png:Class;
//${ASSETS_END}
}

//${TRANSCODE_BEGIN}

// Actionscript Monkey runtime.
//
// Placed into the public domain 24/02/2011.
// No warranty implied; use at your own risk.

//***** ActionScript Runtime *****

import flash.display.*;
import flash.external.ExternalInterface;

//Consts for radians<->degrees conversions
var D2R:Number=0.017453292519943295;
var R2D:Number=57.29577951308232;

//private
var _errInfo:String="?<?>";
var _errStack:Array=[];

var dbg_index:int=0;

function pushErr():void{
	_errStack.push( _errInfo );
}

function popErr():void{
	_errInfo=_errStack.pop();
}

function stackTrace():String{
	if( !_errInfo.length ) return "";
	var str:String=_errInfo+"\n";
	for( var i:int=_errStack.length-1;i>0;--i ){
		str+=_errStack[i]+"\n";
	}
	return str;
}

function print( str:String ):int{
	try{
		if( ExternalInterface.available ) ExternalInterface.call( "monkey_print",str );
	}catch( ex:Error ){
	}
	return 0;
}

function error( err:String ):int{
	throw err;
}

function debugLog( str:String ):int{
	print( str );
	return 0;
}

function debugStop():int{
	error( "STOP" );
	return 0;
}

function dbg_object( obj:Object ):Object{
	if( obj ) return obj;
	error( "Null object access" );
	return obj;
}

function dbg_array( arr:Array,index:int ):Array{
	if( index<0 || index>=arr.length ) error( "Array index out of range" );
	dbg_index=index;
	return arr;
}

function dbg_charCodeAt( str:String,index:int ):int{
	if( index<0 || index>=str.length ) error( "Character index out of range" );
	return str.charCodeAt( index );
}

function new_bool_array( len:int ):Array{
	var arr:Array=new Array( len )
	for( var i:int=0;i<len;++i ) arr[i]=false;
	return arr;
}

function new_number_array( len:int ):Array{
	var arr:Array=new Array( len )
	for( var i:int=0;i<len;++i ) arr[i]=0;
	return arr;
}

function new_string_array( len:int ):Array{
	var arr:Array=new Array( len );
	for( var i:int=0;i<len;++i ) arr[i]='';
	return arr;
}

function new_array_array( len:int ):Array{
	var arr:Array=new Array( len );
	for( var i:int=0;i<len;++i ) arr[i]=[];
	return arr;
}

function new_object_array( len:int ):Array{
	var arr:Array=new Array( len );
	for( var i:int=0;i<len;++i ) arr[i]=null;
	return arr;
}

function resize_bool_array( arr:Array,len:int ):Array{
	var i:int=arr.length;
	arr=arr.slice(0,len);
	if( len<=i ) return arr;
	arr.length=len;
	while( i<len ) arr[i++]=false;
	return arr;
}

function resize_number_array( arr:Array,len:int ):Array{
	var i:int=arr.length;
	arr=arr.slice(0,len);
	if( len<=i ) return arr;
	arr.length=len;
	while( i<len ) arr[i++]=0;
	return arr;
}

function resize_string_array( arr:Array,len:int ):Array{
	var i:int=arr.length;
	arr=arr.slice(0,len);
	if( len<=i ) return arr;
	arr.length=len;
	while( i<len ) arr[i++]="";
	return arr;
}

function resize_array_array( arr:Array,len:int ):Array{
	var i:int=arr.length;
	arr=arr.slice(0,len);
	if( len<=i ) return arr;
	arr.length=len;
	while( i<len ) arr[i++]=[];
	return arr;
}

function resize_object_array( arr:Array,len:int ):Array{
	var i:int=arr.length;
	arr=arr.slice(0,len);
	if( len<=i ) return arr;
	arr.length=len;
	while( i<len ) arr[i++]=null;
	return arr;
}

function string_compare( lhs:String,rhs:String ):int{
	var n:int=Math.min( lhs.length,rhs.length ),i:int,t:int;
	for( i=0;i<n;++i ){
		t=lhs.charCodeAt(i)-rhs.charCodeAt(i);
		if( t ) return t;
	}
	return lhs.length-rhs.length;
}

function string_replace( str:String,find:String,rep:String ):String{	//no unregex replace all?!?
	var i:int=0;
	for(;;){
		i=str.indexOf( find,i );
		if( i==-1 ) return str;
		str=str.substring( 0,i )+rep+str.substring( i+find.length );
		i+=rep.length;
	}
	return str;
}

function string_trim( str:String ):String{
	var i:int=0,i2:int=str.length;
	while( i<i2 && str.charCodeAt(i)<=32 ) i+=1;
	while( i2>i && str.charCodeAt(i2-1)<=32 ) i2-=1;
	return str.slice( i,i2 );
}

function string_tochars( str:String ):Array{
	var arr:Array=new Array( str.length );
	for( var i:int=0;i<str.length;++i ) arr[i]=str.charCodeAt(i);
	return arr;	
}

function string_startswith( str:String,sub:String ):Boolean{
	return sub.length<=str.length && str.slice(0,sub.length)==sub;
}

function string_endswith( str:String,sub:String ):Boolean{
	return sub.length<=str.length && str.slice(str.length-sub.length,str.length)==sub;
}

function string_fromchars( chars:Array ):String{
	var str:String="",i:int;
	for( i=0;i<chars.length;++i ){
		str+=String.fromCharCode( chars[i] );
	}
	return str;
}

class ThrowableObject{
	internal function toString():String{
		return "Uncaught Monkey Exception";
	}
}


import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import flash.utils.ByteArray;

import flash.ui.*;

class BBGameEvent{
	public static const KeyDown:int=1;
	public static const KeyUp:int=2;
	public static const KeyChar:int=3;
	public static const MouseDown:int=4;
	public static const MouseUp:int=5;
	public static const MouseMove:int=6;
	public static const TouchDown:int=7;
	public static const TouchUp:int=8;
	public static const TouchMove:int=9;
	public static const MotionAccel:int=10;
}

class BBGameDelegate{
	public function StartGame():void{}
	public function SuspendGame():void{}
	public function ResumeGame():void{}
	public function UpdateGame():void{}
	public function RenderGame():void{}
	public function KeyEvent( event:int,data:int ):void{}
	public function MouseEvent( event:int,data:int,x:Number,y:Number ):void{}
	public function TouchEvent( event:int,data:int,x:Number,y:Number ):void{}
	public function MotionEvent( event:int,data:int,x:Number,y:Number,z:Number ):void{}
	public function DiscardGraphics():void{}
}

class BBDisplayMode{
	public var width:int;
	public var height:int;
}

class BBGame{

	internal static var _game:BBGame;

	internal var _delegate:BBGameDelegate;
	internal var _keyboardEnabled:Boolean;
	internal var _updateRate:int;
	internal var _debugExs:Boolean;
	internal var _started:Boolean;
	internal var _suspended:Boolean;
	internal var _startms:Number;
	
	public function BBGame(){
		_game=this;
		_debugExs=(Config.CONFIG=="debug");
		_startms=(new Date).getTime();
	}
	
	public static function Game():BBGame{
		return _game;
	}
	
	public function SetDelegate( delegate:BBGameDelegate ):void{
		_delegate=delegate;
	}
	
	public function Delegate():BBGameDelegate{
		return _delegate;
	}
	
	public function SetKeyboardEnabled( enabled:Boolean ):void{
		_keyboardEnabled=enabled;
	}
	
	public function SetUpdateRate( hertz:int ):void{
		_updateRate=hertz;
	}
	
	public function Started():Boolean{
		return _started;
	}
	
	public function Suspended():Boolean{
		return _suspended;
	}
	
	public function Millisecs():int{
		return (new Date).getTime()-_startms;
	}
	
	public function GetDate( date:Array ):void{
		var n:int=date.length;
		if( n>0 ){
			var t:Date=new Date();
			date[0]=t.getFullYear();
			if( n>1 ){
				date[1]=t.getMonth()+1;
				if( n>2 ){
					date[2]=t.getDate();
					if( n>3 ){
						date[3]=t.getHours();
						if( n>4 ){
							date[4]=t.getMinutes();
							if( n>5 ){
								date[5]=t.getSeconds();
								if( n>6 ){
									date[6]=t.getMilliseconds();
								}
							}
						}
					}
				}
			}
		}
	}
	
	public function SaveState( state:String ):int{
		var file:SharedObject=SharedObject.getLocal( "monkeystate" );
		file.data.state=state;
		file.close();
		return 0;
	}
	
	public function LoadState():String{
		var file:SharedObject=SharedObject.getLocal( "monkeystate" );
		var state:String=file.data.state;
		file.close();
		if( state ) return state;
		return "";
	}

	public function LoadString( path:String ):String{
		var buf:ByteArray=LoadData( path );
		if( buf ) return buf.toString();
		return "";
	}
	
	public function PollJoystick( port:int,joyx:Array,joyy:Array,joyz:Array,buttons:Array ):Boolean{
		return false;
	}
	
	public function OpenUrl( url:String ):void{
		navigateToURL( new URLRequest( url ) );
	}
	
	public function SetMouseVisible( visible:Boolean ):void{
		if( visible ){
			Mouse.show();
		}else{
			Mouse.hide();
		}
	}
	
	public function GetDeviceWidth():int{
		return 0;
	}
	
	public function GetDeviceHeight():int{
		return 0;
	}
	
	public function SetDeviceWindow( width:int,height:int,flags:int ):void{
	}
	
	public function GetDisplayModes():Array{
		return new Array();
	}
	
	public function GetDesktopMode():BBDisplayMode{
		return null;
	}
	
	public function SetSwapInterval( interval:int ):void{
	}
	
	public function PathToFilePath( path:String ):String{
		return "";
	}
	
	//***** Flash Game *****
	
	public function PathToUrl( path:String ):String{
		return path;
	}
	
	public function LoadData( path:String ):ByteArray{
		//TODO: Load from URL
		return null;
	}
	
	//***** INTERNAL *****
	public function Die( ex:Object ):void{
	
		_delegate=new BBGameDelegate();
		
		if( !ex.toString() ){
			return;
		}
		if( _debugExs ){
			print( "Monkey Runtime Error : "+ex.toString() );
			print( stackTrace() );
		}
		throw ex;
	}
	
	public function StartGame():void{
	
		if( _started ) return;
		_started=true;
		
		try{
			_delegate.StartGame();
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function SuspendGame():void{
	
		if( !_started || _suspended ) return;
		_suspended=true;
		
		try{
			_delegate.SuspendGame();
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function ResumeGame():void{

		if( !_started || !_suspended ) return;
		_suspended=false;
		
		try{
			_delegate.ResumeGame();
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function UpdateGame():void{

		if( !_started || _suspended ) return;
		
		try{
			_delegate.UpdateGame();
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function RenderGame():void{

		if( !_started ) return;
		
		try{
			_delegate.RenderGame();
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function KeyEvent( ev:int,data:int ):void{

		if( !_started ) return;
		
		try{
			_delegate.KeyEvent( ev,data );
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function MouseEvent( ev:int,data:int,x:Number,y:Number ):void{

		if( !_started ) return;
		
		try{
			_delegate.MouseEvent( ev,data,x,y );
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function TouchEvent( ev:int,data:int,x:Number,y:Number ):void{

		if( !_started ) return;
		
		try{
			_delegate.TouchEvent( ev,data,x,y );
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function MotionEvent( ev:int,data:int,x:Number,y:Number,z:Number ):void{

		if( !_started ) return;
		
		try{
			_delegate.MotionEvent( ev,data,x,y,z );
		}catch( ex:Object ){
			Die( ex );
		}
	}
	
	public function DiscardGraphics():void{

		if( !_started ) return;
		
		try{
			_delegate.DiscardGraphics();
		}catch( ex:Object ){
			Die( ex );
		}
	}
}


class BBFlashGame extends BBGame{

	internal static var _flashGame:BBFlashGame;
	
	internal var _root:DisplayObjectContainer;
	
	internal var _nextUpdate:Number;
	internal var _updatePeriod:Number;

	public function BBFlashGame( root:DisplayObjectContainer ){
		_flashGame=this;
		_root=root;
	}
	
	public static function FlashGame():BBFlashGame{
		return _flashGame;
	}
	
	internal function KeyToChar( key:int ):int{
		switch( key ){
		case 8:case 9:case 13:case 27:return key;
		case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 45:return key | 0x10000;
		case 46:return 127;
		}
		return 0;
	}
	
	internal function ValidateUpdateTimer():void{
		if( _suspended ){
			_root.stage.frameRate=24;
		}else if( _updateRate ){
			_updatePeriod=1000.0/_updateRate;
			_nextUpdate=0;
			_root.stage.frameRate=_updateRate;
		}else{
			_root.stage.frameRate=60;
		}
	}
	
	//***** BBGame *****	
	
	public override function GetDeviceWidth():int{
		return _root.stage.stageWidth;
	}
	
	public override function GetDeviceHeight():int{
		return _root.stage.stageHeight;
	}
	
	public override function SetUpdateRate( hertz:int ):void{
		super.SetUpdateRate( hertz );
		ValidateUpdateTimer();
	}
	
	public override function PathToUrl( path:String ):String {
		if( path.indexOf( "monkey:" )!=0 ){
			return path;
		}else if( path.indexOf( "monkey://data/" )==0 ){
			return "data/"+path.slice( 14 );
		}
		return "";
	}

	public override function LoadData( path:String ):ByteArray{
		var t:Class=GetAsset( path );
		if( t ) return (new t) as ByteArray;
		return null;
	}

	public function GetDisplayObjectContainer():DisplayObjectContainer{
		return _root;
	}

	public function GetAsset( path:String ):Class{
		if( path.indexOf( "monkey://data/" )!=0 ) return null;

		path=path.slice(14);
		
		var i:int=path.indexOf( "." ),ext:String="";
		if( i!=-1 ){
			ext=path.slice(i+1);
			path=path.slice(0,i);
		}

		var munged:String="_";
		var bits:Array=path.split( "/" );
		
		for( i=0;i<bits.length;++i ){
			munged+=bits[i].length+bits[i];
		}
		munged+=ext.length+ext;
		
		return Assets[munged];
	}
	
	public function LoadBitmap( path:String ):Bitmap{
		var t:Class=GetAsset( path );
		if( t ) return (new t) as Bitmap;
		return null;
	}
	
	public function LoadSound( path:String ):Sound{
		var t:Class=GetAsset( path );
		if( t ) return (new t) as Sound;
		return null;
	}
	
	//***** INTERNAL *****
	
	public override function SuspendGame():void{
		super.SuspendGame();
		super.RenderGame();
		ValidateUpdateTimer();
	}
	
	public override function ResumeGame():void{
		super.ResumeGame();
		ValidateUpdateTimer();
	}

	public function Run():void{

		_root.stage.addEventListener( Event.ACTIVATE,OnActivate );
		_root.stage.addEventListener( Event.DEACTIVATE,OnDeactivate );
		_root.stage.addEventListener( Event.ENTER_FRAME,OnEnterFrame );
		_root.stage.addEventListener( KeyboardEvent.KEY_DOWN,OnKeyDown );
		_root.stage.addEventListener( KeyboardEvent.KEY_UP,OnKeyUp );
		_root.stage.addEventListener( flash.events.MouseEvent.MOUSE_DOWN,OnMouseDown );
		_root.stage.addEventListener( flash.events.MouseEvent.MOUSE_UP,OnMouseUp );
		_root.stage.addEventListener( flash.events.MouseEvent.MOUSE_MOVE,OnMouseMove );
		
		StartGame();
	}

	public function OnActivate( e:Event ):void{
		if( Config.MOJO_AUTO_SUSPEND_ENABLED=="1" ) ResumeGame();
	}
	
	public function OnDeactivate( e:Event ):void{
		if( Config.MOJO_AUTO_SUSPEND_ENABLED=="1" ) SuspendGame();
	}
	
	public function OnEnterFrame( e:Event ):void{
		if( _suspended ){
			if( Config.FLASH_RENDER_WHILE_SUSPENDED=="1" ) RenderGame();
			return;
		}
		
		if( !_updateRate ){
			UpdateGame();
			RenderGame();
			return;
		}
		
		if( !_nextUpdate ) _nextUpdate=(new Date).getTime();
		
		var i:int;
		for( i=0;i<4;++i ){
		
			UpdateGame();
			if( !_nextUpdate ) break;
			
			_nextUpdate+=_updatePeriod;
			if( (new Date).getTime()<_nextUpdate ) break;
		}
		if( i==4 ) _nextUpdate=0;
		RenderGame();
	}
	
	public function OnKeyDown( e:KeyboardEvent ):void{
		KeyEvent( BBGameEvent.KeyDown,e.keyCode );
		if( e.charCode!=0 ){
			KeyEvent( BBGameEvent.KeyChar,e.charCode );
		}else{
			var chr:int=KeyToChar( e.keyCode );
			if( chr ) KeyEvent( BBGameEvent.KeyChar,chr );
		}
	}

	public function OnKeyUp( e:KeyboardEvent ):void{
		KeyEvent( BBGameEvent.KeyUp,e.keyCode );
	}
		
	public function OnMouseDown( e:flash.events.MouseEvent ):void{
		MouseEvent( BBGameEvent.MouseDown,0,e.localX,e.localY );
	}
		
	public function OnMouseUp( e:flash.events.MouseEvent ):void{
		MouseEvent( BBGameEvent.MouseUp,0,e.localX,e.localY );
	}

	public function OnMouseMove( e:flash.events.MouseEvent ):void{
		MouseEvent( BBGameEvent.MouseMove,-1,e.localX,e.localY );
	}

}


class BBMonkeyGame extends BBFlashGame{

	internal static var _monkeyGame:BBMonkeyGame;
	
	public function BBMonkeyGame( root:DisplayObjectContainer ){
		super( root );
	}
	
	public static function Main( root:DisplayObjectContainer ):void{
		
		_monkeyGame=new BBMonkeyGame( root );

		try{
		
			bbInit();
			bbMain();
			
		}catch( ex:Object ){
		
			_monkeyGame.Die( ex );
			return;
		}
		
		if( !_monkeyGame.Delegate() ) return;
		
		_monkeyGame.Run();
	}
}


// Flash mojo runtime.
//
// Copyright 2011 Mark Sibly, all rights reserved.
// No warranty implied; use at your own risk.

import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.geom.*;
import flash.utils.*;
import flash.net.*;

class gxtkGraphics{

	internal var game:BBFlashGame;
	internal var stage:Stage;

	internal var bitmap:Bitmap;
	
	internal var red:Number=255;
	internal var green:Number=255;
	internal var blue:Number=255;
	internal var alpha:Number=1;
	internal var colorARGB:uint=0xffffffff;
	internal var colorTform:ColorTransform=null;
	internal var alphaTform:ColorTransform=null;
	
	internal var matrix:Matrix;
	internal var rectBMData:BitmapData;
	internal var blend:String;
	internal var clipRect:Rectangle;
	
	internal var shape:Shape;
	internal var graphics:Graphics;
	internal var bitmapData:BitmapData;
	
	internal var graphics_dirty:Boolean;

	internal var pointMat:Matrix=new Matrix;
	internal var rectMat:Matrix=new Matrix;
	internal var imageMat:Matrix=new Matrix;
	internal var pointCoords:Point=new Point;
	
	internal var image_filtering_enabled:Boolean;
	
	function gxtkGraphics(){

		game=BBFlashGame.FlashGame();
		stage=game.GetDisplayObjectContainer().stage;
		
		image_filtering_enabled=(Config.MOJO_IMAGE_FILTERING_ENABLED=="1");
		
		bitmap=new Bitmap();
		bitmap.bitmapData=new BitmapData( stage.stageWidth,stage.stageHeight,false,0xff0000ff );
		bitmap.smoothing=image_filtering_enabled;
		bitmap.width=stage.stageWidth;
		bitmap.height=stage.stageHeight;
		
		game.GetDisplayObjectContainer().addChild( bitmap );

		shape=new Shape;
		graphics=shape.graphics;
		bitmapData=bitmap.bitmapData;
	
		stage.addEventListener( Event.RESIZE,OnResize );
	
		rectBMData=new BitmapData( 1,1,false,0xffffffff );
		
		image_filtering_enabled=(Config.MOJO_IMAGE_FILTERING_ENABLED=="1");
	}
	
	internal function OnResize( e:Event ):void{
		var w:int=stage.stageWidth;
		var h:int=stage.stageHeight;
		if( w==bitmap.width && h==bitmap.height ) return;
		bitmap.bitmapData=new BitmapData( w,h,false,0xff0000ff );
		bitmap.width=w;
		bitmap.height=h;
	}

	internal function BeginRender():int{
		return 1;
	}

	internal function UseGraphics():void{
		if( graphics_dirty && alphaTform ){
			bitmapData.draw( shape,matrix,alphaTform,blend,clipRect,false );
			graphics.clear();
			return;
		}
		graphics_dirty=true;
	}

	internal function FlushGraphics():void{
		if( graphics_dirty ){
			graphics_dirty=false;
			bitmapData.draw( shape,matrix,alphaTform,blend,clipRect,false );
			graphics.clear();
		}
	}
	
	internal function EndRender():void{
		FlushGraphics();
	}
	
	internal function DiscardGraphics():void{
	}
	
	internal function updateColor():void{
	
		colorARGB=(int(alpha*255)<<24)|(int(red)<<16)|(int(green)<<8)|int(blue);
		
		if( colorARGB==0xffffffff ){
			colorTform=null;
			alphaTform=null;
		}else{
			colorTform=new ColorTransform( red/255.0,green/255.0,blue/255.0,alpha );
			if( alpha==1 ){
				alphaTform=null;
			}else{
				alphaTform=new ColorTransform( 1,1,1,alpha );
			}
		}
	}

	//***** GXTK API *****

	public function Width():int{
		return bitmap.width;
	}

	public function Height():int{
		return bitmap.height;
	}
	
	public function LoadSurface__UNSAFE__( surface:gxtkSurface,path:String ):gxtkSurface{
		return null;
	}

	public function LoadSurface( path:String ):gxtkSurface{
		var bitmap:Bitmap=game.LoadBitmap( path );
		if( bitmap==null ) return null;
		return new gxtkSurface( bitmap );
	}
	
	public function CreateSurface( width:int,height:int ):gxtkSurface{
		var bitmapData:BitmapData=new BitmapData( width,height,true,0 );
		var bitmap:Bitmap=new Bitmap( bitmapData );
		return new gxtkSurface( bitmap );
	}
	
	public function SetAlpha( a:Number ):int{
		FlushGraphics();
		
		alpha=a;
		
		updateColor();
		
		return 0;
	}
	
	public function SetColor( r:Number,g:Number,b:Number ):int{
		FlushGraphics();
		
		red=r;
		green=g;
		blue=b;
		
		updateColor();
		
		return 0;
	}
	
	public function SetBlend( blend:int ):int{
		switch( blend ){
		case 1:
			this.blend=BlendMode.ADD;
			break;
		default:
			this.blend=null;
		}
		return 0;
	}
	
	public function SetScissor( x:int,y:int,w:int,h:int ):int{
		FlushGraphics();
		
		if( x!=0 || y!=0 || w!=bitmap.width || h!=bitmap.height ){
			clipRect=new Rectangle( x,y,w,h );
		}else{
			clipRect=null;
		}
		return 0;
	}

	public function SetMatrix( ix:Number,iy:Number,jx:Number,jy:Number,tx:Number,ty:Number ):int{
		FlushGraphics();
		
		if( ix!=1 || iy!=0 || jx!=0 || jy!=1 || tx!=0 || ty!=0 ){
			matrix=new Matrix( ix,iy,jx,jy,tx,ty );
		}else{
			matrix=null;
		}
		return 0;
	}

	public function Cls( r:Number,g:Number,b:Number ):int{
		FlushGraphics();

		var clsColor:uint=0xff000000|(int(r)<<16)|(int(g)<<8)|int(b);
		var rect:Rectangle=clipRect;
		if( !rect ) rect=new Rectangle( 0,0,bitmap.width,bitmap.height );
		bitmapData.fillRect( rect,clsColor );
		return 0;
	}
	
	public function DrawPoint( x:Number,y:Number ):int{
		FlushGraphics();
		
		if( matrix ){
			var px:Number=x;
			x=px * matrix.a + y * matrix.c + matrix.tx;
			y=px * matrix.b + y * matrix.d + matrix.ty;
		}
		if( clipRect || alphaTform || blend ){
			pointMat.tx=x;pointMat.ty=y;
			bitmapData.draw( rectBMData,pointMat,colorTform,blend,clipRect,false );
		}else{
			bitmapData.fillRect( new Rectangle( x,y,1,1 ),colorARGB );
		}
		return 0;
	}
	
	
	public function DrawRect( x:Number,y:Number,w:Number,h:Number ):int{
		FlushGraphics();
		
		if( matrix ){
			var mat:Matrix=new Matrix( w,0,0,h,x,y );
			mat.concat( matrix );
			bitmapData.draw( rectBMData,mat,colorTform,blend,clipRect,false );
		}else if( clipRect || alphaTform || blend ){
			rectMat.a=w;rectMat.d=h;rectMat.tx=x;rectMat.ty=y;
			bitmapData.draw( rectBMData,rectMat,colorTform,blend,clipRect,false );
		}else{
			bitmapData.fillRect( new Rectangle( x,y,w,h ),colorARGB );
		}
		return 0;
	}

	public function DrawLine( x1:Number,y1:Number,x2:Number,y2:Number ):int{
		
		if( matrix ){
		
			FlushGraphics();
			
			var x1_t:Number=x1 * matrix.a + y1 * matrix.c + matrix.tx;
			var y1_t:Number=x1 * matrix.b + y1 * matrix.d + matrix.ty;
			var x2_t:Number=x2 * matrix.a + y2 * matrix.c + matrix.tx;
			var y2_t:Number=x2 * matrix.b + y2 * matrix.d + matrix.ty;
			
			graphics.lineStyle( 1,colorARGB & 0xffffff );	//why the mask?
			graphics.moveTo( x1_t,y1_t );
			graphics.lineTo( x2_t,y2_t );
			graphics.lineStyle();
			
			bitmapData.draw( shape,null,alphaTform,blend,clipRect,false );
			graphics.clear();
			
		}else{
		
			UseGraphics();

			graphics.lineStyle( 1,colorARGB & 0xffffff );	//why the mask?
			graphics.moveTo( x1,y1 );
			graphics.lineTo( x2,y2 );
			graphics.lineStyle();
		}

		return 0;
 	}

	public function DrawOval( x:Number,y:Number,w:Number,h:Number ):int{
		UseGraphics();

		graphics.beginFill( colorARGB & 0xffffff );			//why the mask?
		graphics.drawEllipse( x,y,w,h );
		graphics.endFill();

		return 0;
	}
	
	public function DrawPoly( verts:Array ):int{
		if( verts.length<2 ) return 0;
		
		UseGraphics();
		
		graphics.beginFill( colorARGB & 0xffffff );			//why the mask?
		
		graphics.moveTo( verts[0],verts[1] );
		for( var i:int=2;i<verts.length;i+=2 ){
			graphics.lineTo( verts[i],verts[i+1] );
		}
		graphics.endFill();
		
		return 0;
	}

	public function DrawPoly2( verts:Array,surface:gxtkSurface,srcx:int,srcy:int ):int{
		if( verts.length<4 ) return 0;
		
		UseGraphics();
		
		graphics.beginFill( colorARGB & 0xffffff );			//why the mask?
		
		graphics.moveTo( verts[0],verts[1] );
		for( var i:int=4;i<verts.length;i+=4 ){
			graphics.lineTo( verts[i],verts[i+1] );
		}
		graphics.endFill();
		
		return 0;
	}

	public function DrawSurface( surface:gxtkSurface,x:Number,y:Number ):int{
		FlushGraphics();
		
		if( matrix ){
			var mat:Matrix=new Matrix( 1,0,0,1,x,y );
			mat.concat( matrix );
			bitmapData.draw( surface.bitmap.bitmapData,mat,colorTform,blend,clipRect,image_filtering_enabled );
		}else if( clipRect || colorTform || blend ){
			imageMat.tx=x;imageMat.ty=y;
			bitmapData.draw( surface.bitmap.bitmapData,imageMat,colorTform,blend,clipRect,image_filtering_enabled );
		}else{
			pointCoords.x=x;pointCoords.y=y;
			bitmapData.copyPixels( surface.bitmap.bitmapData,surface.rect,pointCoords );
		}

		return 0;
	}

	public function DrawSurface2( surface:gxtkSurface,x:Number,y:Number,srcx:int,srcy:int,srcw:int,srch:int ):int{
		if( srcw<0 ){ srcx+=srcw;srcw=-srcw; }
		if( srch<0 ){ srcy+=srch;srch=-srch; }
		if( srcw<=0 || srch<=0 ) return 0;
		
		FlushGraphics();

		var srcrect:Rectangle=new Rectangle( srcx,srcy,srcw,srch );
		
		if( matrix || clipRect || colorTform || blend ){

			var scratch:BitmapData=surface.scratch;
			if( scratch==null || srcw!=scratch.width || srch!=scratch.height ){
				if( scratch!=null ) scratch.dispose();
				scratch=new BitmapData( srcw,srch );
				surface.scratch=scratch;
			}
			pointCoords.x=0;pointCoords.y=0;
			scratch.copyPixels( surface.bitmap.bitmapData,srcrect,pointCoords );
			
			var mat:Matrix;
			if( matrix ){
				mat=new Matrix( 1,0,0,1,x,y );
				mat.concat( matrix );
			}else{
				imageMat.tx=x;imageMat.ty=y;
				mat=imageMat;
			}
			bitmapData.draw( scratch,mat,colorTform,blend,clipRect,image_filtering_enabled );
		}else{
			pointCoords.x=x;pointCoords.y=y;
			bitmapData.copyPixels( surface.bitmap.bitmapData,srcrect,pointCoords );
		}
		return 0;
	}
	
	public function ReadPixels( pixels:Array,x:int,y:int,width:int,height:int,offset:int,pitch:int ):int{
	
		FlushGraphics();
		
		var data:ByteArray=bitmapData.getPixels( new Rectangle( x,y,width,height ) );
		data.position=0;
		
		var px:int,py:int,j:int=offset,argb:int;
		
		for( py=0;py<height;++py ){
			for( px=0;px<width;++px ){
				pixels[j++]=data.readInt();
			}
			j+=pitch-width;
		}
		
		return 0;
	}
	
	public function WritePixels2( surface:gxtkSurface,pixels:Array,x:int,y:int,width:int,height:int,offset:int,pitch:int ):int{

		FlushGraphics();
		
		var data:ByteArray=new ByteArray();
		data.length=width*height;
			
		var px:int,py:int,j:int=offset,argb:int;
		
		for( py=0;py<height;++py ){
			for( px=0;px<width;++px ){
				data.writeInt( pixels[j++] );
			}
			j+=pitch-width;
		}
		data.position=0;
		
		surface.bitmap.bitmapData.setPixels( new Rectangle( x,y,width,height ),data );
		
		return 0;
	}
}

//***** gxtkSurface *****

class gxtkSurface{
	internal var bitmap:Bitmap;
	internal var rect:Rectangle;
	internal var scratch:BitmapData;
	
	function gxtkSurface( bitmap:Bitmap ){
		SetBitmap( bitmap );
	}
	
	public function SetBitmap( bitmap:Bitmap ):void{
		this.bitmap=bitmap;
		rect=new Rectangle( 0,0,bitmap.width,bitmap.height );
	}

	//***** GXTK API *****

	public function Discard():int{
		return 0;
	}
	
	public function Width():int{
		return rect.width;
	}

	public function Height():int{
		return rect.height;
	}

	public function Loaded():int{
		return 1;
	}
	
	public function OnUnsafeLoadComplete():Boolean{
		return true;
	}
}

class gxtkChannel{
	internal var channel:SoundChannel;	//null then not playing
	internal var sample:gxtkSample;
	internal var loops:Boolean;
	internal var transform:SoundTransform=new SoundTransform();
	internal var pausepos:Number;
	internal var state:int;				//0=stopped, 1=playing, 2=paused, 5=playing/suspended
}

class gxtkAudio{

	internal var busy:Boolean;

	internal var game:BBFlashGame;
	internal var music:gxtkSample;

	internal var channels:Array=new Array( 33 );

	function gxtkAudio(){
		game=BBFlashGame.FlashGame();
		for( var i:int=0;i<33;++i ){
			channels[i]=new gxtkChannel();
		}
	}
	
	internal function SoundComplete( ev:Event ):void{

		//Should never happen!	
		if( busy ){
			debugLog( "gxtkAudio.SoundComplete Error - audio is busy!" );
			return;
		}
		
		busy=true;
		
		for( var i:int=0;i<33;++i ){
			var chan:gxtkChannel=channels[i];
			if( chan.state==1 && chan.channel==ev.target ){
				if( chan.loops ){
					chan.channel=chan.sample.sound.play( 0,0,chan.transform );
					if( chan.channel ){
						chan.channel.addEventListener( Event.SOUND_COMPLETE,SoundComplete );
						continue;
					}
				}
				chan.channel=null;
				chan.sample=null;
				chan.state=0;
			}
		}
		
		busy=false;
	}
	
	//***** GXTK API *****
	
	public function Suspend():int{
	
		busy=true;
		
		for( var i:int=0;i<33;++i ){
			var chan:gxtkChannel=channels[i];
			if( chan.state==1 ){
				chan.pausepos=chan.channel.position;
				chan.channel.stop();
				chan.channel=null;
				chan.state=5;
			}
		}
		
		busy=false;
		
		return 0;
	}
	
	public function Resume():int{
	
		busy=true;
		
		for( var i:int=0;i<33;++i ){
			var chan:gxtkChannel=channels[i];
			if( chan.state==5 ){
				chan.channel=chan.sample.sound.play( chan.pausepos,0,chan.transform );
				if( chan.channel ){
					chan.channel.addEventListener( Event.SOUND_COMPLETE,SoundComplete );
					chan.state=1;
					continue;
				}
				
				debugLog( "gxtkAudio.Resume() - failed to create SoundChannel" );
				
				chan.sample=null;
				chan.state=0;
			}
		}
		
		busy=false;
		
		return 0;
	}
	
	public function LoadSample__UNSAFE__( sample:gxtkSample,path:String ):gxtkSample{
		return null;
	}
	
	public function LoadSample( path:String ):gxtkSample{
		var sound:Sound=game.LoadSound( path );
		if( sound ) return new gxtkSample( sound );
		return null;
	}
	
	public function PlaySample( sample:gxtkSample,channel:int,flags:int ):int{
		var chan:gxtkChannel=channels[channel];
		
		busy=true;
		
		if( chan.state!=0 ) chan.channel.stop();

		chan.sample=sample;
		chan.loops=(flags & 1)!=0;
		chan.channel=sample.sound.play( 0,0,chan.transform );
		if( chan.channel ){
			chan.channel.addEventListener( Event.SOUND_COMPLETE,SoundComplete );
			chan.state=1;
		}else{
			chan.sample=null;
			chan.state=0;
		}
		
		busy=false;

		return 0;
	}
	
	public function StopChannel( channel:int ):int{
		var chan:gxtkChannel=channels[channel];
		
		busy=true;
		
		if( chan.state!=0 ){
			if( chan.state==1 ){
				chan.channel.stop();
				chan.channel=null;
			}
			chan.sample=null;
			chan.state=0;
		}
		
		busy=false;
		
		return 0;
	}
	
	public function PauseChannel( channel:int ):int{
		var chan:gxtkChannel=channels[channel];
		
		busy=true;
		
		if( chan.state==1 ){
			chan.pausepos=chan.channel.position;
			chan.channel.stop();
			chan.channel=null;
			chan.state=2;
		}
		
		busy=false;
		
		return 0;
	}
	
	public function ResumeChannel( channel:int ):int{
		var chan:gxtkChannel=channels[channel];
		
		busy=true;
		
		if( chan.state==2 ){
			chan.channel=chan.sample.sound.play( chan.pausepos,0,chan.transform );
			if( chan.channel ){
				chan.channel.addEventListener( Event.SOUND_COMPLETE,SoundComplete );
				chan.state=1;
			}else{
				chan.sample=null;
				chan.state=0;
			}
		}
		
		busy=false;
		
		return 0;
	}
	
	public function ChannelState( channel:int ):int{
		var chan:gxtkChannel=channels[channel];
		
		return chan.state & 3;
	}
	
	public function SetVolume( channel:int,volume:Number ):int{
		var chan:gxtkChannel=channels[channel];
		
		chan.transform.volume=volume;

		if( chan.state==1 ) chan.channel.soundTransform=chan.transform;

		return 0;
	}
	
	public function SetPan( channel:int,pan:Number ):int{
		var chan:gxtkChannel=channels[channel];
		
		chan.transform.pan=pan;

		if( chan.state==1 ) chan.channel.soundTransform=chan.transform;

		return 0;
	}
	
	public function SetRate( channel:int,rate:Number ):int{
		return -1;
	}
	
	public function PlayMusic( path:String,flags:int ):int{
		StopMusic();
		
		music=LoadSample( path );
		if( !music ) return -1;
		
		PlaySample( music,32,flags );
		return 0;
	}
	
	public function StopMusic():int{
		StopChannel( 32 );
		
		if( music ){
			music.Discard();
			music=null;
		}
		return 0;
	}
	
	public function PauseMusic():int{
		PauseChannel( 32 );
		
		return 0;
	}
	
	public function ResumeMusic():int{
		ResumeChannel( 32 );
		
		return 0;
	}
	
	public function MusicState():int{
		return ChannelState( 32 );
	}
	
	public function SetMusicVolume( volume:Number ):int{
		SetVolume( 32,volume );
		return 0;
	}
}

class gxtkSample{

	internal var sound:Sound;

	function gxtkSample( sound:Sound ){
		this.sound=sound;
	}
	
	public function Discard():int{
		return 0;
	}
	
}


class BBThread{

	internal var result:Object=null;
	internal var running:Boolean=false;
	
	public function Start():void{
		result=null;
		running=true;
		Run__UNSAFE__();
	}
	
	public function IsRunning():Boolean{
		return running;
	}
	
	public function Result():Object{
		return result;
	}
	
	public function Run__UNSAFE__():void{
		running=false;
	}
}


class BBAsyncImageLoaderThread{

	internal var _running:Boolean=false;
	
	internal var _device:gxtkGraphics;
	internal var _path:String;
	internal var _surface:gxtkSurface;

	public function Start():void{
		
		var thread:BBAsyncImageLoaderThread=this;
		
		var loader:Loader=new Loader();
		
		loader.contentLoaderInfo.addEventListener( Event.COMPLETE,onLoaded );
		loader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR,onIoError );
		loader.contentLoaderInfo.addEventListener( SecurityErrorEvent.SECURITY_ERROR,onSecurityError );
		
		function onLoaded( e:Event ):void{
			thread._surface=new gxtkSurface( e.target.content );
			thread._running=false;
		}
		
		function onIoError( e:IOErrorEvent ):void{
			thread._surface=null;
			thread._running=false;
		}

		function onSecurityError( e:SecurityErrorEvent ):void{
			thread._surface=null;
			thread._running=false;
		}
		
		thread._running=true;
		
		loader.load( new URLRequest( BBGame.Game().PathToUrl( thread._path ) ) );
	}
	
	public function IsRunning():Boolean{
		return _running;
	}
}


class BBAsyncSoundLoaderThread{

	internal var _running:Boolean;
	
	internal var _device:gxtkAudio;
	internal var _path:String;
	internal var _sample:gxtkSample;

	public function Start():void{
		
		var thread:BBAsyncSoundLoaderThread=this;
		
		var sound:Sound=new Sound();
		
		sound.addEventListener( Event.COMPLETE,onLoaded );
		sound.addEventListener( IOErrorEvent.IO_ERROR,onIoError );
		sound.addEventListener( SecurityErrorEvent.SECURITY_ERROR,onSecurityError );
		
		function onLoaded( e:Event ):void{
			thread._sample=new gxtkSample( sound );
			thread._running=false;
		}
		
		function onIoError( e:IOErrorEvent ):void{
			thread._sample=null;
			thread._running=false;
		}

		function onSecurityError( e:SecurityErrorEvent ):void{
			thread._sample=null;
			thread._running=false;
		}
		
		thread._running=true;
		
		sound.load( new URLRequest( BBGame.Game().PathToUrl( thread._path ) ) );
	}
	
	public function IsRunning():Boolean{
		return _running;
	}
}


class BBDataBuffer{

	internal var _data:ByteArray=null;
	internal var _length:int=0;
	
	public function _Init( data:ByteArray ):void{
		_data=data;
		_length=data.length;
	}
	
	public function _New( length:int ):Boolean{
		if( _data ) return false
		_data=new ByteArray;
		_data.length=length;
		_length=length;
		return true;
	}
	
	public function _Load( path:String ):Boolean{
		if( _data ) return false
		var data:ByteArray=BBGame.Game().LoadData( path );
		if( !data ) return false;
		_Init( data );
		return true;
	}
	
	public function _LoadAsync( path:String,thread:BBThread ):void{

		var buf:BBDataBuffer=this;
		
		var loader:URLLoader=new URLLoader();
		loader.dataFormat=URLLoaderDataFormat.BINARY;
		loader.addEventListener( Event.COMPLETE,onLoaded );
		loader.addEventListener( IOErrorEvent.IO_ERROR,onError );
		
		function onLoaded( e:Event ):void{
			buf._Init( loader.data );
			thread.result=buf;
			thread.running=false;
		}
		
		function onError( e:IOErrorEvent ):void{
			thread.running=false;
		}
		
		loader.load( new URLRequest( BBGame.Game().PathToUrl( path ) ) );
	}

	public function GetByteArray():ByteArray{
		return _data;
	}
	
	public function Discard():void{
		if( _data ){
			_data.clear();
			_data=null;
			_length=0;
		}
	}
	
	public function Length():int{
		return _length;
	}
	
	public function PokeByte( addr:int,value:int ):void{
		_data.position=addr;
		_data.writeByte( value );
	}
	
	public function PokeShort( addr:int,value:int ):void{
		_data.position=addr;
		_data.writeShort( value );
	}
	
	public function PokeInt( addr:int,value:int ):void{
		_data.position=addr;
		_data.writeInt( value );
	}
	
	public function PokeFloat( addr:int,value:Number ):void{
		_data.position=addr;
		_data.writeFloat( value );
	}
	
	public function PeekByte( addr:int ):int{
		_data.position=addr;
		return _data.readByte();
	}
	
	public function PeekShort( addr:int ):int{
		_data.position=addr;
		return _data.readShort();
	}

	public function PeekInt( addr:int ):int{
		_data.position=addr;
		return _data.readInt();
	}
	
	public function PeekFloat( addr:int ):Number{
		_data.position=addr;
		return _data.readFloat();
	}
}


import flash.display.Stage3D;
import flash.display3D.*;
import flash.display3D.textures.Texture;
import flash.system.Capabilities;
//import com.adobe.utils.AGALMiniAssembler;

class EmptyNullClass extends gxtkSurface
{
	protected var bitmap_null:Bitmap = new Bitmap;
	
	override public function EmptyNullClass() {
		super(bitmap_null);
	};
	
	override public function Width():int {return 0;};
	override public function Height():int {return 0;};
	override public function Discard():int {return 0;};
	override public function Loaded():int {return 1;};
	override public function OnUnsafeLoadComplete():Boolean {return true;};
};

class Driver3D
{
	protected var game:BBFlashGame;
	protected var stage:Stage;
	
	public var context3d:Context3D;
	//protected var program:Program3D;
	protected var vertexbuffer:VertexBuffer3D;
	protected var indexbuffer:IndexBuffer3D;
	
	protected var width:int, height:int, alias:int;
	protected var contextReady:Boolean = false;
	
	private static var mojo_clear:Boolean = false;
	
	public function SetContext__(c:Context3D):void {
		context3d = c;
	}
	public function GetContext__():Context3D {
		return context3d;
	}
	
	public function CheckVersion():String
	{
		return Capabilities.version;
	}
	
	public function EnableErrorChecking_(b:Boolean):void {
		context3d.enableErrorChecking = b;
	}
	
	public function InitContext(w:int, h:int, al:int, flags:int):void {
		width = w; height = h; alias = al;
		
		game=BBFlashGame.FlashGame();
		stage=game.GetDisplayObjectContainer().stage;

		stage.stage3Ds[0].addEventListener( Event.CONTEXT3D_CREATE, Init3D );
		stage.stage3Ds[0].addEventListener( ErrorEvent.ERROR, contextCreationError );
		stage.stage3Ds[0].requestContext3D(); //auto, profile=baseline
		
		
	}
	
	public function Init3D(e:Event):void {
		//print("**************");
		context3d = stage.stage3Ds[0].context3D;			
		context3d.configureBackBuffer(width, height, alias, true);
		contextReady = true;
	}
	
	public function ContextReady():Boolean {
		return contextReady;
	}
	
	private function contextCreationError( error:ErrorEvent ):void
	{
		trace( error.errorID + ": " + error.text );
	}
	
	
	public  function UploadTextureData(tex:Texture, pix:TPixmap, miplevel:uint):int {
		try {
			tex.uploadFromBitmapData(pix.pixels, miplevel);
		} catch (e:Error) {
			//ran out of memory or pixels are gone
			return 0;
		}
		return 1;
	}
	

	public  function UploadConstantsFromArray( programType:String, firstRegister:int, data:Array, byteArrayOffset:uint):void {
		
		if (firstRegister >-1) {

			var mvec:Vector.<Number> = Vector.<Number>(data);
			//for (var i:int=0; i< (data.length); i++) { print (mvec[i].toString()); };
			
			context3d.setProgramConstantsFromVector(programType, firstRegister, mvec, data.length >> 2);
		};
	}
	
	
	public  function UploadIndexFromDataBuffer(ib:IndexBuffer3D, data:BBDataBuffer, byteArrayOffset:int, startVertex:int, numVertices:int):void {
//print("indexlen");
//print(String(data._data.length));
//print(data.Length().toString());	
		var d:ByteArray = data.GetByteArray();
		d.endian = Endian.LITTLE_ENDIAN;
		d.position=0;
		ib.uploadFromByteArray(d , byteArrayOffset, startVertex, numVertices);
		
	}
	
	public  function UploadVertexFromDataBuffer(vb:VertexBuffer3D, data:BBDataBuffer, byteArrayOffset:int, startVertex:int, numVertices:int):void {
//print("vblen");
//print(String(data._data.length));
//print(data.Length().toString());
		var d:ByteArray = data.GetByteArray();
		d.endian = Endian.LITTLE_ENDIAN;
		d.position=0;
		vb.uploadFromByteArray(d , byteArrayOffset, startVertex, numVertices);
		
	}
	
	public  function SetScissorRectangle_(x:int,y:int,w:int,h:int):void {
		context3d.setScissorRectangle( new Rectangle(x,y,w,h) );
	}
	
	public function Present():void {
		context3d.present();
	}
	
	public function PresentToDevice(g:gxtkGraphics):void {
		// ugh.... may break if mojo changes
		//context3d.drawToBitmapData( app.graphics.bitmapData );
		//if (!g.bitmap.bitmapData.transparent) {
			//g.bitmap.bitmapData=new BitmapData( stage.stageWidth,stage.stageHeight,true,0x00505050 );
			//mojo_clear = true
			//if (game.GetDisplayObjectContainer().contains(g.bitmap)) { game.GetDisplayObjectContainer().removeChild(g.bitmap);}
		//}
		context3d.present();
	}

	public static function DataBufferLittleEndian(b:BBDataBuffer):void {
		b.GetByteArray().endian = Endian.LITTLE_ENDIAN;
	}
	
	public function ForceDeviceTransparency(g:gxtkGraphics):void {
		g.bitmap.bitmapData=new BitmapData( stage.stageWidth,stage.stageHeight,true,0x00505050 );
		//if (game.GetDisplayObjectContainer().contains(g.bitmap)) { game.GetDisplayObjectContainer().removeChild(g.bitmap);}
		//print("xxx");
	}

}
/*
Copyright (c) 2011, Adobe Systems Incorporated
All rights reserved.

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the 
documentation and/or other materials provided with the distribution.

* Neither the name of Adobe Systems Incorporated nor the names of its 
contributors may be used to endorse or promote products derived from 
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


	// ===========================================================================
	//	Imports
	// ---------------------------------------------------------------------------
	//import flash.display3D.*;
	import flash.utils.*;
	
	// ===========================================================================
	//	Class
	// ---------------------------------------------------------------------------
	 class AGALMiniAssembler
	{
		// ======================================================================
		//	Properties
		// ----------------------------------------------------------------------
		// AGAL bytes and error buffer 
		private var _agalcode:ByteArray							= null;
		private var _error:String								= "";
		
		private var debugEnabled:Boolean						= false;
		
		private static var initialized:Boolean					= false;
		
		// ======================================================================
		//	Getters
		// ----------------------------------------------------------------------
		public function get error():String						{ return _error; }
		public function get agalcode():ByteArray				{ return _agalcode; }
		
		// ======================================================================
		//	Constructor
		// ----------------------------------------------------------------------
		public function AGALMiniAssembler( debugging:Boolean = false ):void
		{
			debugEnabled = debugging;
			if ( !initialized )
				init();
		}
		// ======================================================================
		//	Methods
		// ----------------------------------------------------------------------
		public function assemble( mode:String, source:String, verbose:Boolean = false ):ByteArray
		{
			var start:uint = getTimer();
			
			_agalcode = new ByteArray();			
			_error = "";
			
			var isFrag:Boolean = false;
			
			if ( mode == FRAGMENT )
				isFrag = true
			else if ( mode != VERTEX )
				_error = 'ERROR: mode needs to be "' + FRAGMENT + '" or "' + VERTEX + '" but is "' + mode + '".';
			
			agalcode.endian = Endian.LITTLE_ENDIAN;
			agalcode.writeByte( 0xa0 );				// tag version
			agalcode.writeUnsignedInt( 0x1 );		// AGAL version, big endian, bit pattern will be 0x01000000
			agalcode.writeByte( 0xa1 );				// tag program id
			agalcode.writeByte( isFrag ? 1 : 0 );	// vertex or fragment
			
			var lines:Array = source.replace( /[\f\n\r\v]+/g, "\n" ).split( "\n" );
			var nest:int = 0;
			var nops:int = 0;
			var i:int;
			var lng:int = lines.length;
			
			for ( i = 0; i < lng && _error == ""; i++ )
			{
				var line:String = new String( lines[i] );
				
				// remove comments
				var startcomment:int = line.search( "//" );
				if ( startcomment != -1 )
					line = line.slice( 0, startcomment );
				
				// grab options
				var optsi:int = line.search( /<.*>/g );
				var opts:Array;
				if ( optsi != -1 )
				{
					opts = line.slice( optsi ).match( /([\w\.\-\+]+)/gi );
					line = line.slice( 0, optsi );
				}
				
				// find opcode
				var opCode:Array = line.match( /^\w{3}/ig );
				var opFound:OpCode = OPMAP[ opCode[0] ];
				
				// if debug is enabled, output the opcodes
				if ( debugEnabled )
					trace( opFound );
				
				if ( opFound == null )
				{
					if ( line.length >= 3 )
						print( "warning: bad line "+i+": "+lines[i] );
					continue;
				}
				
				line = line.slice( line.search( opFound.name ) + opFound.name.length );
				
				// nesting check
				if ( opFound.flags & OP_DEC_NEST )
				{
					nest--;
					if ( nest < 0 )
					{
						_error = "error: conditional closes without open.";
						break;
					}
				}
				if ( opFound.flags & OP_INC_NEST )
				{
					nest++;
					if ( nest > MAX_NESTING )
					{
						_error = "error: nesting to deep, maximum allowed is "+MAX_NESTING+".";
						break;
					}
				}
				if ( ( opFound.flags & OP_FRAG_ONLY ) && !isFrag )
				{
					_error = "error: opcode is only allowed in fragment programs.";
					break;
				}
				if ( verbose )
					print( "emit opcode=" + opFound );
				
				agalcode.writeUnsignedInt( opFound.emitCode );
				nops++;
				
				if ( nops > MAX_OPCODES )
				{
					_error = "error: too many opcodes. maximum is "+MAX_OPCODES+".";
					break;
				}
				
				// get operands, use regexp
				var regs:Array = line.match( /vc\[([vof][actps]?)(\d*)?(\.[xyzw](\+\d{1,3})?)?\](\.[xyzw]{1,4})?|([vof][actps]?)(\d*)?(\.[xyzw]{1,4})?/gi );
				if ( regs.length != opFound.numRegister )
				{
					_error = "error: wrong number of operands. found "+regs.length+" but expected "+opFound.numRegister+".";
					break;
				}
				
				var badreg:Boolean	= false;
				var pad:uint		= 64 + 64 + 32;
				var regLength:uint	= regs.length;
				
				for ( var j:int = 0; j < regLength; j++ )
				{
					var isRelative:Boolean = false;
					var relreg:Array = regs[ j ].match( /\[.*\]/ig );
					if ( relreg.length > 0 )
					{
						regs[ j ] = regs[ j ].replace( relreg[ 0 ], "0" );
						
						if ( verbose )
							print( "IS REL" );
						isRelative = true;
					}
					
					var res:Array = regs[j].match( /^\b[A-Za-z]{1,2}/ig );
					var regFound:Register = REGMAP[ res[ 0 ] ];
					
					// if debug is enabled, output the registers
					if ( debugEnabled )
						trace( regFound );
					
					if ( regFound == null )
					{
						_error = "error: could not parse operand "+j+" ("+regs[j]+").";
						badreg = true;
						break;
					}
					
					if ( isFrag )
					{
						if ( !( regFound.flags & REG_FRAG ) )
						{
							_error = "error: register operand "+j+" ("+regs[j]+") only allowed in vertex programs.";
							badreg = true;
							break;
						}
						if ( isRelative )
						{
							_error = "error: register operand "+j+" ("+regs[j]+") relative adressing not allowed in fragment programs.";
							badreg = true;
							break;
						}			
					}
					else
					{
						if ( !( regFound.flags & REG_VERT ) )
						{
							_error = "error: register operand "+j+" ("+regs[j]+") only allowed in fragment programs.";
							badreg = true;
							break;
						}
					}
					
					regs[j] = regs[j].slice( regs[j].search( regFound.name ) + regFound.name.length );
					//print( "REGNUM: " +regs[j] );
					var idxmatch:Array = isRelative ? relreg[0].match( /\d+/ ) : regs[j].match( /\d+/ );
					var regidx:uint = 0;
					
					if ( idxmatch )
						regidx = uint( idxmatch[0] );
					
					if ( regFound.range < regidx )
					{
						_error = "error: register operand "+j+" ("+regs[j]+") index exceeds limit of "+(regFound.range+1)+".";
						badreg = true;
						break;
					}
					
					var regmask:uint		= 0;
					var maskmatch:Array		= regs[j].match( /(\.[xyzw]{1,4})/ );
					var isDest:Boolean		= ( j == 0 && !( opFound.flags & OP_NO_DEST ) );
					var isSampler:Boolean	= ( j == 2 && ( opFound.flags & OP_SPECIAL_TEX ) );
					var reltype:uint		= 0;
					var relsel:uint			= 0;
					var reloffset:int		= 0;
					
					if ( isDest && isRelative )
					{
						_error = "error: relative can not be destination";	
						badreg = true; 
						break;								
					}
					
					if ( maskmatch )
					{
						regmask = 0;
						var cv:uint; 
						var maskLength:uint = maskmatch[0].length;
						for ( var k:int = 1; k < maskLength; k++ )
						{
							cv = maskmatch[0].charCodeAt(k) - "x".charCodeAt(0);
							if ( cv > 2 )
								cv = 3;
							if ( isDest )
								regmask |= 1 << cv;
							else
								regmask |= cv << ( ( k - 1 ) << 1 );
						}
						if ( !isDest )
							for ( ; k <= 4; k++ )
								regmask |= cv << ( ( k - 1 ) << 1 ) // repeat last								
					}
					else
					{
						regmask = isDest ? 0xf : 0xe4; // id swizzle or mask						
					}
					
					if ( isRelative )
					{
						var relname:Array = relreg[0].match( /[A-Za-z]{1,2}/ig );						
						var regFoundRel:Register = REGMAP[ relname[0]];						
						if ( regFoundRel == null )
						{ 
							_error = "error: bad index register"; 
							badreg = true; 
							break;
						}
						reltype = regFoundRel.emitCode;
						var selmatch:Array = relreg[0].match( /(\.[xyzw]{1,1})/ );						
						if ( selmatch.length==0 )
						{
							_error = "error: bad index register select"; 
							badreg = true; 
							break;						
						}
						relsel = selmatch[0].charCodeAt(1) - "x".charCodeAt(0);
						if ( relsel > 2 )
							relsel = 3; 
						var relofs:Array = relreg[0].match( /\+\d{1,3}/ig );
						if ( relofs.length > 0 ) 
							reloffset = relofs[0]; 						
						if ( reloffset < 0 || reloffset > 255 )
						{
							_error = "error: index offset "+reloffset+" out of bounds. [0..255]"; 
							badreg = true; 
							break;							
						}
						if ( verbose )
							print( "RELATIVE: type="+reltype+"=="+relname[0]+" sel="+relsel+"=="+selmatch[0]+" idx="+regidx+" offset="+reloffset ); 
					}
					
					if ( verbose )
						print( "  emit argcode="+regFound+"["+regidx+"]["+regmask+"]" );
					if ( isDest )
					{												
						agalcode.writeShort( regidx );
						agalcode.writeByte( regmask );
						agalcode.writeByte( regFound.emitCode );
						pad -= 32; 
					} else
					{
						if ( isSampler )
						{
							if ( verbose )
								print( "  emit sampler" );
							var samplerbits:uint = 5; // type 5 
							var optsLength:uint = opts.length;
							var bias:Number = 0; 
							for ( k = 0; k<optsLength; k++ )
							{
								if ( verbose )
									print( "    opt: "+opts[k] );
								var optfound:Sampler = SAMPLEMAP [opts[k]];
								if ( optfound == null )
								{
									// todo check that it's a number...
									//print( "Warning, unknown sampler option: "+opts[k] );
									bias = Number(opts[k]); 
									if ( verbose )
										print( "    bias: " + bias );																	
								}
								else
								{
									if ( optfound.flag != SAMPLER_SPECIAL_SHIFT )
										samplerbits &= ~( 0xf << optfound.flag );										
									samplerbits |= uint( optfound.mask ) << uint( optfound.flag );
								}
							}
							agalcode.writeShort( regidx );
							agalcode.writeByte(int(bias*8.0));
							agalcode.writeByte(0);							
							agalcode.writeUnsignedInt( samplerbits );
							
							if ( verbose )
								print( "    bits: " + ( samplerbits - 5 ) );
							pad -= 64;
						}
						else
						{
							if ( j == 0 )
							{
								agalcode.writeUnsignedInt( 0 );
								pad -= 32;
							}
							agalcode.writeShort( regidx );
							agalcode.writeByte( reloffset );
							agalcode.writeByte( regmask );
							agalcode.writeByte( regFound.emitCode );
							agalcode.writeByte( reltype );
							agalcode.writeShort( isRelative ? ( relsel | ( 1 << 15 ) ) : 0 );
							
							pad -= 64;
						}
					}
				}
				
				// pad unused regs
				for ( j = 0; j < pad; j += 8 ) 
					agalcode.writeByte( 0 );
				
				if ( badreg )
					break;
			}
			
			if ( _error != "" )
			{
				_error += "\n  at line " + i + " " + lines[i];
				agalcode.length = 0;
				print( _error );
			}
			
			// trace the bytecode bytes if debugging is enabled
			if ( debugEnabled )
			{
				var dbgLine:String = "generated bytecode:";
				var agalLength:uint = agalcode.length;
				for ( var index:uint = 0; index < agalLength; index++ )
				{
					if ( !( index % 16 ) )
						dbgLine += "\n";
					if ( !( index % 4 ) )
						dbgLine += " ";
					
					var byteStr:String = agalcode[ index ].toString( 16 );
					if ( byteStr.length < 2 )
						byteStr = "0" + byteStr;
					
					dbgLine += byteStr;
				}
				print( dbgLine );
			}
			
			if ( verbose )
				print( "AGALMiniAssembler.assemble time: " + ( ( getTimer() - start ) / 1000 ) + "s" );
			
			return agalcode;
		}
		
		static private function init():void
		{
			initialized = true;
			
			// Fill the dictionaries with opcodes and registers
			OPMAP[ MOV ] = new OpCode( MOV, 2, 0x00, 0 );
			OPMAP[ ADD ] = new OpCode( ADD, 3, 0x01, 0 );
			OPMAP[ SUB ] = new OpCode( SUB, 3, 0x02, 0 );
			OPMAP[ MUL ] = new OpCode( MUL, 3, 0x03, 0 );
			OPMAP[ DIV ] = new OpCode( DIV, 3, 0x04, 0 );
			OPMAP[ RCP ] = new OpCode( RCP, 2, 0x05, 0 );					
			OPMAP[ MIN ] = new OpCode( MIN, 3, 0x06, 0 );
			OPMAP[ MAX ] = new OpCode( MAX, 3, 0x07, 0 );
			OPMAP[ FRC ] = new OpCode( FRC, 2, 0x08, 0 );			
			OPMAP[ SQT ] = new OpCode( SQT, 2, 0x09, 0 );
			OPMAP[ RSQ ] = new OpCode( RSQ, 2, 0x0a, 0 );
			OPMAP[ POW ] = new OpCode( POW, 3, 0x0b, 0 );
			OPMAP[ LOG ] = new OpCode( LOG, 2, 0x0c, 0 );
			OPMAP[ EXP ] = new OpCode( EXP, 2, 0x0d, 0 );
			OPMAP[ NRM ] = new OpCode( NRM, 2, 0x0e, 0 );
			OPMAP[ SIN ] = new OpCode( SIN, 2, 0x0f, 0 );
			OPMAP[ COS ] = new OpCode( COS, 2, 0x10, 0 );
			OPMAP[ CRS ] = new OpCode( CRS, 3, 0x11, 0 );
			OPMAP[ DP3 ] = new OpCode( DP3, 3, 0x12, 0 );
			OPMAP[ DP4 ] = new OpCode( DP4, 3, 0x13, 0 );					
			OPMAP[ ABS ] = new OpCode( ABS, 2, 0x14, 0 );
			OPMAP[ NEG ] = new OpCode( NEG, 2, 0x15, 0 );
			OPMAP[ SAT ] = new OpCode( SAT, 2, 0x16, 0 );
			OPMAP[ M33 ] = new OpCode( M33, 3, 0x17, OP_SPECIAL_MATRIX );
			OPMAP[ M44 ] = new OpCode( M44, 3, 0x18, OP_SPECIAL_MATRIX );
			OPMAP[ M34 ] = new OpCode( M34, 3, 0x19, OP_SPECIAL_MATRIX );			
			OPMAP[ IFZ ] = new OpCode( IFZ, 1, 0x1a, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ INZ ] = new OpCode( INZ, 1, 0x1b, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ IFE ] = new OpCode( IFE, 2, 0x1c, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ INE ] = new OpCode( INE, 2, 0x1d, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ IFG ] = new OpCode( IFG, 2, 0x1e, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ IFL ] = new OpCode( IFL, 2, 0x1f, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ IEG ] = new OpCode( IEG, 2, 0x20, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ IEL ] = new OpCode( IEL, 2, 0x21, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ ELS ] = new OpCode( ELS, 0, 0x22, OP_NO_DEST | OP_INC_NEST | OP_DEC_NEST );
			OPMAP[ EIF ] = new OpCode( EIF, 0, 0x23, OP_NO_DEST | OP_DEC_NEST );
			OPMAP[ REP ] = new OpCode( REP, 1, 0x24, OP_NO_DEST | OP_INC_NEST | OP_SCALAR );
			OPMAP[ ERP ] = new OpCode( ERP, 0, 0x25, OP_NO_DEST | OP_DEC_NEST );
			OPMAP[ BRK ] = new OpCode( BRK, 0, 0x26, OP_NO_DEST );
			OPMAP[ KIL ] = new OpCode( KIL, 1, 0x27, OP_NO_DEST | OP_FRAG_ONLY );
			OPMAP[ TEX ] = new OpCode( TEX, 3, 0x28, OP_FRAG_ONLY | OP_SPECIAL_TEX );
			OPMAP[ SGE ] = new OpCode( SGE, 3, 0x29, 0 );
			OPMAP[ SLT ] = new OpCode( SLT, 3, 0x2a, 0 );
			OPMAP[ SGN ] = new OpCode( SGN, 2, 0x2b, 0 );
			
			REGMAP[ VA ]	= new Register( VA,	"vertex attribute",		0x0,	7,		REG_VERT | REG_READ );
			REGMAP[ VC ]	= new Register( VC,	"vertex constant",		0x1,	127,	REG_VERT | REG_READ );
			REGMAP[ VT ]	= new Register( VT,	"vertex temporary",		0x2,	7,		REG_VERT | REG_WRITE | REG_READ );
			REGMAP[ OP ]	= new Register( OP,	"vertex output",		0x3,	0,		REG_VERT | REG_WRITE );
			REGMAP[ V ]		= new Register( V,	"varying",				0x4,	7,		REG_VERT | REG_FRAG | REG_READ | REG_WRITE );
			REGMAP[ FC ]	= new Register( FC,	"fragment constant",	0x1,	27,		REG_FRAG | REG_READ );
			REGMAP[ FT ]	= new Register( FT,	"fragment temporary",	0x2,	7,		REG_FRAG | REG_WRITE | REG_READ );
			REGMAP[ FS ]	= new Register( FS,	"texture sampler",		0x5,	7,		REG_FRAG | REG_READ );
			REGMAP[ OC ]	= new Register( OC,	"fragment output",		0x3,	0,		REG_FRAG | REG_WRITE );
			
			SAMPLEMAP[ D2 ]			= new Sampler( D2,			SAMPLER_DIM_SHIFT,		0 );
			SAMPLEMAP[ D3 ]			= new Sampler( D3,			SAMPLER_DIM_SHIFT,		2 );
			SAMPLEMAP[ CUBE ]		= new Sampler( CUBE,		SAMPLER_DIM_SHIFT,		1 );
			SAMPLEMAP[ MIPNEAREST ]	= new Sampler( MIPNEAREST,	SAMPLER_MIPMAP_SHIFT,	1 );
			SAMPLEMAP[ MIPLINEAR ]	= new Sampler( MIPLINEAR,	SAMPLER_MIPMAP_SHIFT,	2 );
			SAMPLEMAP[ MIPNONE ]	= new Sampler( MIPNONE,		SAMPLER_MIPMAP_SHIFT,	0 );
			SAMPLEMAP[ NOMIP ]		= new Sampler( NOMIP,		SAMPLER_MIPMAP_SHIFT,	0 );
			SAMPLEMAP[ NEAREST ]	= new Sampler( NEAREST,		SAMPLER_FILTER_SHIFT,	0 );
			SAMPLEMAP[ LINEAR ]		= new Sampler( LINEAR,		SAMPLER_FILTER_SHIFT,	1 );
			SAMPLEMAP[ CENTROID ]	= new Sampler( CENTROID,	SAMPLER_SPECIAL_SHIFT,	1 << 0 );
			SAMPLEMAP[ SINGLE ]		= new Sampler( SINGLE,		SAMPLER_SPECIAL_SHIFT,	1 << 1 );
			SAMPLEMAP[ DEPTH ]		= new Sampler( DEPTH,		SAMPLER_SPECIAL_SHIFT,	1 << 2 );
			SAMPLEMAP[ REPEAT ]		= new Sampler( REPEAT,		SAMPLER_REPEAT_SHIFT,	1 );
			SAMPLEMAP[ WRAP ]		= new Sampler( WRAP,		SAMPLER_REPEAT_SHIFT,	1 );
			SAMPLEMAP[ CLAMP ]		= new Sampler( CLAMP,		SAMPLER_REPEAT_SHIFT,	0 );
		}
		
		// ======================================================================
		//	Constants
		// ----------------------------------------------------------------------
		private static const OPMAP:Dictionary					= new Dictionary();
		private static const REGMAP:Dictionary					= new Dictionary();
		private static const SAMPLEMAP:Dictionary				= new Dictionary();
		
		private static const MAX_NESTING:int					= 4;
		private static const MAX_OPCODES:int					= 256;
		
		private static const FRAGMENT:String					= "fragment";
		private static const VERTEX:String						= "vertex";
		
		// masks and shifts
		private static const SAMPLER_DIM_SHIFT:uint				= 12;
		private static const SAMPLER_SPECIAL_SHIFT:uint			= 16;
		private static const SAMPLER_REPEAT_SHIFT:uint			= 20;
		private static const SAMPLER_MIPMAP_SHIFT:uint			= 24;
		private static const SAMPLER_FILTER_SHIFT:uint			= 28;
		
		// regmap flags
		private static const REG_WRITE:uint						= 0x1;
		private static const REG_READ:uint						= 0x2;
		private static const REG_FRAG:uint						= 0x20;
		private static const REG_VERT:uint						= 0x40;
		
		// opmap flags
		private static const OP_SCALAR:uint						= 0x1;
		private static const OP_INC_NEST:uint					= 0x2;
		private static const OP_DEC_NEST:uint					= 0x4;
		private static const OP_SPECIAL_TEX:uint				= 0x8;
		private static const OP_SPECIAL_MATRIX:uint				= 0x10;
		private static const OP_FRAG_ONLY:uint					= 0x20;
		private static const OP_VERT_ONLY:uint					= 0x40;
		private static const OP_NO_DEST:uint					= 0x80;
		
		// opcodes
		private static const MOV:String							= "mov";
		private static const ADD:String							= "add";
		private static const SUB:String							= "sub";
		private static const MUL:String							= "mul";
		private static const DIV:String							= "div";
		private static const RCP:String							= "rcp";
		private static const MIN:String							= "min";
		private static const MAX:String							= "max";
		private static const FRC:String							= "frc";
		private static const SQT:String							= "sqt";
		private static const RSQ:String							= "rsq";
		private static const POW:String							= "pow";
		private static const LOG:String							= "log";
		private static const EXP:String							= "exp";
		private static const NRM:String							= "nrm";
		private static const SIN:String							= "sin";
		private static const COS:String							= "cos";
		private static const CRS:String							= "crs";
		private static const DP3:String							= "dp3";
		private static const DP4:String							= "dp4";
		private static const ABS:String							= "abs";
		private static const NEG:String							= "neg";
		private static const SAT:String							= "sat";
		private static const M33:String							= "m33";
		private static const M44:String							= "m44";
		private static const M34:String							= "m34";
		private static const IFZ:String							= "ifz";
		private static const INZ:String							= "inz";
		private static const IFE:String							= "ife";
		private static const INE:String							= "ine";
		private static const IFG:String							= "ifg";
		private static const IFL:String							= "ifl";
		private static const IEG:String							= "ieg";
		private static const IEL:String							= "iel";
		private static const ELS:String							= "els";
		private static const EIF:String							= "eif";
		private static const REP:String							= "rep";
		private static const ERP:String							= "erp";
		private static const BRK:String							= "brk";
		private static const KIL:String							= "kil";
		private static const TEX:String							= "tex";
		private static const SGE:String							= "sge";
		private static const SLT:String							= "slt";
		private static const SGN:String							= "sgn";
		
		// registers
		private static const VA:String							= "va";
		private static const VC:String							= "vc";
		private static const VT:String							= "vt";
		private static const OP:String							= "op";
		private static const V:String							= "v";
		private static const FC:String							= "fc";
		private static const FT:String							= "ft";
		private static const FS:String							= "fs";
		private static const OC:String							= "oc";
		
		// samplers
		private static const D2:String							= "2d";
		private static const D3:String							= "3d";
		private static const CUBE:String						= "cube";
		private static const MIPNEAREST:String					= "mipnearest";
		private static const MIPLINEAR:String					= "miplinear";
		private static const MIPNONE:String						= "mipnone";
		private static const NOMIP:String						= "nomip";
		private static const NEAREST:String						= "nearest";
		private static const LINEAR:String						= "linear";
		private static const CENTROID:String					= "centroid";
		private static const SINGLE:String						= "single";
		private static const DEPTH:String						= "depth";
		private static const REPEAT:String						= "repeat";
		private static const WRAP:String						= "wrap";
		private static const CLAMP:String						= "clamp";
	}


// ================================================================================
//	Helper Classes
// --------------------------------------------------------------------------------

	// ===========================================================================
	//	Class
	// ---------------------------------------------------------------------------
	class OpCode
	{		
		// ======================================================================
		//	Properties
		// ----------------------------------------------------------------------
		private var _emitCode:uint;
		private var _flags:uint;
		private var _name:String;
		private var _numRegister:uint;
		
		// ======================================================================
		//	Getters
		// ----------------------------------------------------------------------
		public function get emitCode():uint		{ return _emitCode; }
		public function get flags():uint		{ return _flags; }
		public function get name():String		{ return _name; }
		public function get numRegister():uint	{ return _numRegister; }
		
		// ======================================================================
		//	Constructor
		// ----------------------------------------------------------------------
		public function OpCode( name:String, numRegister:uint, emitCode:uint, flags:uint)
		{
			_name = name;
			_numRegister = numRegister;
			_emitCode = emitCode;
			_flags = flags;
		}		
		
		// ======================================================================
		//	Methods
		// ----------------------------------------------------------------------
		public function toString():String
		{
			return "[OpCode name=\""+_name+"\", numRegister="+_numRegister+", emitCode="+_emitCode+", flags="+_flags+"]";
		}
	}
	
	// ===========================================================================
	//	Class
	// ---------------------------------------------------------------------------
	class Register
	{
		// ======================================================================
		//	Properties
		// ----------------------------------------------------------------------
		private var _emitCode:uint;
		private var _name:String;
		private var _longName:String;
		private var _flags:uint;
		private var _range:uint;
		
		// ======================================================================
		//	Getters
		// ----------------------------------------------------------------------
		public function get emitCode():uint		{ return _emitCode; }
		public function get longName():String	{ return _longName; }
		public function get name():String		{ return _name; }
		public function get flags():uint		{ return _flags; }
		public function get range():uint		{ return _range; }
		
		// ======================================================================
		//	Constructor
		// ----------------------------------------------------------------------
		public function Register( name:String, longName:String, emitCode:uint, range:uint, flags:uint)
		{
			_name = name;
			_longName = longName;
			_emitCode = emitCode;
			_range = range;
			_flags = flags;
		}
		
		// ======================================================================
		//	Methods
		// ----------------------------------------------------------------------
		public function toString():String
		{
			return "[Register name=\""+_name+"\", longName=\""+_longName+"\", emitCode="+_emitCode+", range="+_range+", flags="+ _flags+"]";
		}
	}
	
	// ===========================================================================
	//	Class
	// ---------------------------------------------------------------------------
	class Sampler
	{
		// ======================================================================
		//	Properties
		// ----------------------------------------------------------------------
		private var _flag:uint;
		private var _mask:uint;
		private var _name:String;
		
		// ======================================================================
		//	Getters
		// ----------------------------------------------------------------------
		public function get flag():uint		{ return _flag; }
		public function get mask():uint		{ return _mask; }
		public function get name():String	{ return _name; }
		
		// ======================================================================
		//	Constructor
		// ----------------------------------------------------------------------
		public function Sampler( name:String, flag:uint, mask:uint )
		{
			_name = name;
			_flag = flag;
			_mask = mask;
		}
		
		// ======================================================================
		//	Methods
		// ----------------------------------------------------------------------
		public function toString():String
		{
			return "[Sampler name=\""+_name+"\", flag=\""+_flag+"\", mask="+mask+"]";
		}
	}


import flash.display.Bitmap;
import flash.display.BitmapData;

class TPixmap {
	
	internal var pixels:BitmapData;
	internal var isLoaded:Boolean=false;
	internal var width:int;
	internal var height:int;
	
	
	private function onComplete (event:Event):void
	{
		pixels = Bitmap(LoaderInfo(event.target).content).bitmapData;
		isLoaded = true;
		width = pixels.width;
		height = pixels.height;
	}
	
	private function onError (e:IOErrorEvent):void
	{
		isLoaded = true;
		width=0; height=0;
	}
	
	
	public static function LoadImageData(file:String):TPixmap {
		var pix:TPixmap = new TPixmap;
		
		var loader:Loader = new Loader();
		loader.contentLoaderInfo.addEventListener(Event.COMPLETE, pix.onComplete);
		loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, pix.onError);
		loader.load(new URLRequest(file));

		return pix;
	}
	
	public static function CreatePixmap(x:int, y:int):TPixmap {
		var pix:TPixmap = new TPixmap;
		pix.pixels = new BitmapData(x, y, true, 0xffffffff);
		pix.width = x; pix.height = y;
		return pix;
	}
	
	public static function ReadPixel(pix:TPixmap, x:int, y:int):uint {
		return pix.pixels.getPixel32(x,y);
	}
	public static function WritePixel(pix:TPixmap, x:int, y:int, rgb:uint):void {
		pix.pixels.setPixel32(x,y, rgb);
	}
	
	public static function ResizePixmap(pix:TPixmap, nw:int, nh:int, smooth:Boolean):TPixmap {
		var newpix:TPixmap = new TPixmap;
		var mat:Matrix = new Matrix();
		
		mat.scale(nw/pix.pixels.width, nh/pix.pixels.height);
		newpix.pixels = new BitmapData(nw, nh, true, 0x00000000);
		newpix.pixels.draw(pix.pixels, mat, null, BlendMode.NORMAL, null, smooth);

		return newpix;
	}
	
	public static function MaskPixmap(pix:TPixmap, threshold:uint):TPixmap {
		
		var newpix:TPixmap = new TPixmap;

		newpix.pixels = new BitmapData(pix.pixels.width, pix.pixels.height, true);
		var pt:Point = new Point(0, 0);
		
		//pix.pixels.threshold(newpix.pixels, newpix.pixels.rect, pt, "==", threshold, 0x00000000, 0x00ffffff, true);
		newpix.pixels.threshold(pix.pixels, pix.pixels.rect, pt, "==", threshold, 0x00000000, 0x00ffffff, true);
		return newpix;
	}
	
	public static function GetInfo(pix:TPixmap):Array {
		return [pix.width, pix.height];
	}
	
	public static function CheckIsLoaded(pix:TPixmap):Boolean {
		return pix.isLoaded;
	}
}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	class CalVector 
	{
		public var x:Number;
		public var y:Number;
		public var z:Number;
		
		
		
		public function CalVector( vx:Number = 0.0, vy:Number = 0.0, vz:Number = 0.0 ):void {
		
			x = vx;
			y = vy;
			z = vz;
		}

		public function getx():Number {
			return x;
		} 

		public function gety():Number {
			return y;
		}
		
		public function getz():Number {
			return z;
		}		
		
		public function toString():String {
			return "[x:" + x + " y:" + y + " z:" + z + " ]";
		}
	

	
		public function clone():CalVector {
			return new CalVector(this.x, this.y, this.z);
			
		}
		
		public function add(v:CalVector):void {
			
			x += v.x;
			y += v.y;
			z += v.z;			
		}

 		public function addlocal(v:CalVector):CalVector{
			
			x += v.x;
			y += v.y;
			z += v.z;

			return this;
		}
		
  		public function set( vx:Number, vy:Number, vz:Number ):void {
		
			x = vx;
			y = vy;
			z = vz;
		}

  		public function setToVector(v:CalVector):void {
		
			trace("CalVector:setToVector -- " + v);
			x = v.x;
			y = v.y;
			z = v.z;
		}
  
		public function subtract(v:CalVector):void {

			x -= v.x;
			y -= v.y;
			z -= v.z;
		}

		public function sublocal(v:CalVector):CalVector {

			x -= v.x;
			y -= v.y;
			z -= v.z;
			
			return this;
		}		
		
		public function multipyByFloat( d:Number ):void {
			
			x *= d;
			y *= d;
			z *= d;
		}

		public function multScalarLocal( d:Number ):CalVector  {
			
			x *= d;
			y *= d;
			z *= d;
			
			return this;
		}		
		
		public function multiplyByMatrix( m:CalMatrix ):void {
			
			var ox:Number = x;
			var oy:Number = y;
			var oz:Number = z;
			x = m.dxdx * ox + m.dxdy * oy + m.dxdz * oz;
			y = m.dydx * ox + m.dydy * oy + m.dydz * oz;
			z = m.dzdx * ox + m.dzdy * oy + m.dzdz * oz;
		}
		
		public function multiplyByQuaternion( q:CalQuaternion ):void {
			
			var temp:CalQuaternion = new CalQuaternion(-q.x, -q.y, -q.z, q.w);
			temp.multiplyByVector(this);
			temp.multiplyByQuaternion(q);

			x = temp.x;
			y = temp.y;
			z = temp.z;
		} 
		
		static public function multiplyVectorByQuaternion( v:CalVector, q:CalQuaternion ):CalVector {
			
			//var temp:CalQuaternion = new CalQuaternion(-q.x, -q.y, -q.z, q.w);
			//temp.multiplyByVector(this);
			//temp.multiplyByQuaternion(q);

			var vx:Number = q.w * v.x             - q.y * v.z + q.z * v.y;
			var vy:Number = q.w * v.y + q.x * v.z             - q.z * v.x;
			var vz:Number = q.w * v.z - q.x * v.y + q.y * v.x;
			var vw:Number =           + q.x * v.x + q.y * v.y + q.z * v.z;
			
			var qx:Number = vx;
			var qy:Number = vy;
			var qz:Number = vz; 
			var qw:Number = vw;			
			
			return new CalVector(
				qw * q.x + qx * q.w + qy * q.z - qz * q.y,
				qw * q.y - qx * q.z + qy * q.w + qz * q.x,
				qw * q.z + qx * q.y - qy * q.x + qz * q.w
			);
			//w = qw * q.w - qx * q.x - qy * q.y - qz * q.z;
		
		
		/*
			var qx:Number = x;
			var qy:Number = y; 
			var qz:Number = z; 
			var qw:Number = w;
			
			x = qw * v.x            + qy * v.z - qz * v.y;
			y = qw * v.y - qx * v.z            + qz * v.x;
			z = qw * v.z + qx * v.y - qy * v.x;
			w =          - qx * v.x - qy * v.y - qz * v.z;
			
			
			var qx:Number = x;
			var qy:Number = y;
			var qz:Number = z; 
			var qw:Number = w;			
			
			x = qw * q.x + qx * q.w + qy * q.z - qz * q.y;
			y = qw * q.y - qx * q.z + qy * q.w + qz * q.x;
			z = qw * q.z + qx * q.y - qy * q.x + qz * q.w;
			w = qw * q.w - qx * q.x - qy * q.y - qz * q.z;
			*/
		
		} 
		
		
		
		public function multiplyByVector( v:CalVector ):Number {
			return v.x * x + v.y * y + v.z * z;
		} 

		public function divideFloat( d:Number ):void {
			x /= d;
			y /= d;
			z /= d;
		}

		public function equals( v:CalVector ):Boolean {
			
			return ((x == v.x) && (y == v.y) && (z == v.z));
		}


		public function blend( d:Number, v:CalVector ):void {
			
			x += d * (v.x - x);
			y += d * (v.y - y);
			z += d * (v.z - z);
		}

		public function clear():void {
			
			x = 0.0;
			y = 0.0;
			z = 0.0;		  
		}

		public function length():Number {
			
			return Number(Math.sqrt(x * x + y * y + z * z));
  		}
  
		public function normalize():Number {
			
			// calculate the length of the vector
			var length:Number;
			length = Number( Math.sqrt(x * x + y * y + z * z) );
	  
			// normalize the vector
			x /= length;
			y /= length;
			z /= length;
	  
			return length;
		}
		
		
		public static function cross(v:CalVector, u:CalVector):CalVector {
			
			return new CalVector(v.y * u.z - v.z * u.y, v.z * u.x - v.x * u.z, v.x * u.y - v.y * u.x);
		}
		
		public static function dot(v:CalVector, u:CalVector):Number {
			
			return  v.x * u.x + v.y * u.y + v.z * u.z;
		}
  
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalQuaternion
	{
		public var x:Number;
		public var y:Number;
		public var z:Number;
		public var w:Number;
		
		public function CalQuaternion(qx:Number=0.0, qy:Number=0.0, qz:Number=0.0, qw:Number=1.0):void {
			
			x = qx;
			y = qy;
			z = qz;
			w = qw;
		}
		
		public function clone():CalQuaternion {
			return new CalQuaternion(x,y,z,w);	
		}
		
		public function toString():String {
			return "[x:" + x + " y:" + y + " z:" + z + " w:" + w + " ]";
		}
		
		public function clear():void {
			
			x = 0.0;
			y = 0.0;
			z = 0.0;
			w = 1.0;				
		}
		
		public function conjugate():void {
			
			x = -x;
			y = -y;
			z = -z;		
		}
		
		public function invert():void {
			
			conjugate();
			var norm:Number	= (x*x) + (y*y) + (z*z) + (w*w);
		
			if (norm == 0.0) return;
			
			var inv_norm:Number = 1 / norm;
			x *= inv_norm;
			y *= inv_norm;
			z *= inv_norm;
			w *= inv_norm;	
		}

		public function set( qx:Number, qy:Number, qz:Number, qw:Number):void {
			
			x = qx;
			y = qy;
			z = qz;
			w = qw;
		}
		
		public function setToQuaternion( q:CalQuaternion ):void {
			
			x = q.x;
			y = q.y;
			z = q.z;
			w = q.w;
		}		
		
		public function multiplyByQuaternion( q:CalQuaternion ):void {

			var qx:Number = x;
			var qy:Number = y;
			var qz:Number = z; 
			var qw:Number = w;			
			
			x = qw * q.x + qx * q.w + qy * q.z - qz * q.y;
			y = qw * q.y - qx * q.z + qy * q.w + qz * q.x;
			z = qw * q.z + qx * q.y - qy * q.x + qz * q.w;
			w = qw * q.w - qx * q.x - qy * q.y - qz * q.z;
		

		}		

		static public function multiplyQuaternions( a:CalQuaternion, b:CalQuaternion ):CalQuaternion {
			
			return new CalQuaternion(
				a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,	//x
				a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,	//y
				a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w,	//z
				a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z	//w
			);

		}
		
		
		public function multiplyVectorByQuaternion( v:CalVector, q:CalQuaternion ):CalQuaternion {
			
			return new CalQuaternion(
				q.w * v.x             + q.y * v.z - q.z * v.y,
				q.w * v.y - q.x * v.z             + q.z * v.x,
				q.w * v.z + q.x * v.y - q.y * v.x,
				          - q.x * v.x - q.y * v.y - q.z * v.z
			)			
		}
		
		
		public function multiplyByVector( v:CalVector ):void {
			
			var qx:Number = x;
			var qy:Number = y; 
			var qz:Number = z; 
			var qw:Number = w;
			
			x = qw * v.x            + qy * v.z - qz * v.y;
			y = qw * v.y - qx * v.z            + qz * v.x;
			z = qw * v.z + qx * v.y - qy * v.x;
			w =          - qx * v.x - qy * v.y - qz * v.z;
						
		}
		
		
		public function equals( rhs:CalQuaternion ):Boolean {
			
			return x == rhs.x &&
				y == rhs.y &&
				z == rhs.z &&
				w == rhs.w;
		}
		
		public function blend(d:Number, q:CalQuaternion):void {
			
			var norm:Number;
			norm = x * q.x + y * q.y + z * q.z + w * q.w;
			
			var bFlip:Boolean;
			bFlip = false;
			
			if(norm < 0.0){
				
				norm = -norm;
				bFlip = true;
			}
			
			var inv_d:Number;
			if(1.0 - norm < 0.000001) {
				
				inv_d = 1.0 - d;
				
			}else{
				
				var theta:Number;
				theta = Number(Math.acos(norm));
				
				var s:Number;
				s = Number( 1.0 / Math.sin(theta) );
				
				inv_d = Number(Math.sin((1.0 - d) * theta)) * s;
				d = Number(Math.sin(d * theta) * s);
			}
			
			if(bFlip){
				d = -d;
			}
			
			x = inv_d * x + d * q.x;
			y = inv_d * y + d * q.y;
			z = inv_d * z + d * q.z;
			w = inv_d * w + d * q.w;
		}

		public function shortestArc( from:CalVector, to:CalVector ):CalQuaternion {
			
			var cross:CalVector = CalVector.cross(from, to); //Compute vector cross product
			var dot:Number = CalVector.dot(from , to) ;      //Compute dot product
			
			dot = Number( Math.sqrt( 2*(dot+1) ) ); //We will use this equation twice
			
			cross.multipyByFloat(dot); //Get the x, y, z components
			
			//Return with the w component (Note that w is inverted because Cal3D has
			// left-handed rotations )
			return new CalQuaternion( cross[0], cross[1], cross[2], -dot/2 ) ; 	
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalMatrix
	{
		public var dxdx:Number = 0.0;
		public var dydx:Number = 0.0;
		public var dzdx:Number = 0.0;
		public var dxdy:Number = 0.0;
		public var dydy:Number = 0.0;
		public var dzdy:Number = 0.0;
		public var dxdz:Number = 0.0;
		public var dydz:Number = 0.0;
		public var dzdz:Number = 0.0;
	
		public function CalMatrix( weight:Number = 0, m:CalMatrix = null ):void {
		
			if(m){
				dxdx = m.dxdx * weight;
				dxdy = m.dxdy * weight;
				dxdz = m.dxdz * weight;
				dydx = m.dydx * weight;
				dydy = m.dydy * weight;
				dydz = m.dydz * weight;
				dzdx = m.dzdx * weight;
				dzdy = m.dzdy * weight;
				dzdz = m.dzdz * weight;
			}
		}
	
		public function clone():CalMatrix{
			
			var cm:CalMatrix = new CalMatrix();
			
			this.dxdx = this.dxdx;
			this.dydx = this.dydx;
			this.dzdx = this.dzdx;
			this.dxdy = this.dxdy;
			this.dydy = this.dydy;
			this.dzdy = this.dzdy;
			this.dxdz = this.dxdz;
			this.dydz = this.dydz;
			this.dzdz = this.dzdz;
			
			return cm;
			
		}
		public function setFromQuaternion( q:CalQuaternion ):void {
		
			var xx2:Number = q.x*q.x*2;
			var yy2:Number = q.y*q.y*2;
			var zz2:Number = q.z*q.z*2;
			var xy2:Number = q.x*q.y*2;
			var zw2:Number = q.z*q.w*2;
 			var xz2:Number = q.x*q.z*2;
			var yw2:Number = q.y*q.w*2;
			var yz2:Number = q.y*q.z*2;
			var xw2:Number = q.x*q.w*2;
			dxdx = 1-yy2-zz2; dxdy = xy2+zw2;	dxdz = xz2-yw2;
			dydx = xy2-zw2;   dydy = 1-xx2-zz2;	dydz = yz2+xw2;
			dzdx = xz2+yw2;   dzdy = yz2-xw2;	dzdz = 1-xx2-yy2;
  
		}
		
		public function set( m:CalMatrix ):void {
		
			dxdx = m.dxdx; dxdy = m.dxdy; dxdz = m.dxdz;
			dydx = m.dydx; dydy = m.dydy; dydz = m.dydz;
			dzdx = m.dzdx; dzdy = m.dzdy; dzdz = m.dzdz;
		}
		
		public function multiplyByMatrix(m:CalMatrix):void {
			
			var ndxdx:Number = m.dxdx*dxdx+m.dxdy*dydx+m.dxdz*dzdx;
			var ndydx:Number = m.dydx*dxdx+m.dydy*dydx+m.dydz*dzdx;
			var ndzdx:Number = m.dzdx*dxdx+m.dzdy*dydx+m.dzdz*dzdx;
			
			var ndxdy:Number = m.dxdx*dxdy+m.dxdy*dydy+m.dxdz*dzdy;
			var ndydy:Number = m.dydx*dxdy+m.dydy*dydy+m.dydz*dzdy;
			var ndzdy:Number = m.dzdx*dxdy+m.dzdy*dydy+m.dzdz*dzdy;
			
			var ndxdz:Number = m.dxdx*dxdz+m.dxdy*dydz+m.dxdz*dzdz;
			var ndydz:Number = m.dydx*dxdz+m.dydy*dydz+m.dydz*dzdz;
			var ndzdz:Number = m.dzdx*dxdz+m.dzdy*dydz+m.dzdz*dzdz;
			
			dxdx = ndxdx;
			dydx = ndydx;
			dzdx = ndzdx;
			dxdy = ndxdy;
			dydy = ndydy;
			dzdy = ndzdy;
			dxdz = ndxdz;
			dydz = ndydz;
			dzdz = ndzdz;
		}
		
		public function multiplyByFloat( factor:Number ):void {
			
			dxdx *= factor;
			dydx *= factor;
			dzdx *= factor;
			dxdy *= factor;
			dydy *= factor;
			dzdy *= factor;
			dxdz *= factor;
			dydz *= factor;
			dzdz *= factor;
		}
		
		public function blend( factor:Number, m:CalMatrix ):void {
			
			dxdx += m.dxdx*factor;
			dydx += m.dydx*factor;
			dzdx += m.dzdx*factor;
			dxdy += m.dxdy*factor;
			dydy += m.dydy*factor;
			dzdy += m.dzdy*factor;
			dxdz += m.dxdz*factor;
			dydz += m.dydz*factor;
			dzdz += m.dzdz*factor;
		}
		
		public function det():Number {
			
			return dxdx * (dydy*dzdz-dydz*dzdy)
	            - dxdy * (dydx*dzdz-dzdx*dydz)
				+ dxdz * (dydx*dzdy-dzdx*dydy);
		}






	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class Vertex
	{
		public var position:CalVector;
		public var normal:CalVector;
		public var vectorInfluence:Array; //	std::vector<Influence> 
		public var collapseId:int;
		public var faceCollapseCount:int;


		public function getx():Number {
			return position.x;
		} 

		public function gety():Number {
			return position.y;
		}
		
		public function getz():Number {
			return position.z;
		}

		
		public function Vertex() {
			vectorInfluence = new Array();
			position = new CalVector();
			normal = new CalVector();
			collapseId = 0;
			faceCollapseCount = 0;
		}
		
		public function clone():Vertex {
			
			var clone:Vertex = new Vertex();
			clone.position = position.clone();
			clone.normal = normal.clone();
			clone.collapseId = collapseId;
			clone.faceCollapseCount = faceCollapseCount;
			
			var influences:Array = new Array();
			for each(var item:Object in vectorInfluence){
				influences.push(item);
			}
			
			clone.vectorInfluence = influences;
			
			return clone;	
		}
		
		public function toString():String {
			
			var s:String = "--Vertex--\n";
			s += "position:" + position + " \n";
			for each(var influence:Influence in vectorInfluence){
				s+="\tinfluence: " + influence + "\n";
			}
			return s;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class Spring
	{
		  /// The core submesh Spring.
 		public var vertexId:Array = new Array(2);
		public var springCoefficient:Number;
		public var idleLength:Number;
		
		public function Spring( vertexIDs:Array, springCoef:Number, idleLength:Number ):void {
			
			this.vertexId = vertexIDs;
			this.springCoefficient = springCoef;
			this.idleLength = idleLength;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class BlendVertex
	{
		public var position:CalVector;
		public var normal:CalVector;
	
		public function BlendVertex( position:CalVector, normal:CalVector ):void {
			this.position = position;
			this.normal = normal;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class Influence
	{
		
		public var boneId:int;
		public var weight:Number;
		
		public function Influence(boneId:int = 0.0, weight:Number = 0.0){
			
			this.boneId = boneId;
			this.weight = weight;
		}

		public function toString():String{
		
			return ("boneID: " + boneId + " weight: " + weight);
		}	
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	class TextureCoordinate
	{
		public var u:Number; 
		public var v:Number;
			
		public function TextureCoordinate(u:Number = 0.0, v:Number = 0.0):void {
			this.u = u;
			this.v = v;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	class PhysicalProperty
	{
		public var weight:Number;
		
		public function PhysicalProperty( weight:Number = 0.0 ):void {
			this.weight = weight;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	class Face
	{
		public var vertexId:Array; //[3]
		
		public function Face( vertexIds:Array ){
			this.vertexId = vertexIds;
		}

		public function Get():Array{
			return this.vertexId;
		}		
		
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
 /*****************************************************************************/
/** The bounding box class.
  *****************************************************************************/

	class CalBoundingBox
	{
		public var plane:Array;
		
		public function CalBoundingBox():void {
			//super();
			this.plane = new Array(6);
		}
		
		//@param points Array of 8 CalVector points
		public function computePoints( points:Array ):void {
			
			var m:CalMatrix;
     
			var i:int;
			var j:int;
			var k:int;
        	
        	var p:int = 0;
        
		    for(i=0;i<2;i++)
				for(j=2;j<4;j++)
		           for(k=4;k<6;k++) {
		           	
			           var x:Number;
			           var y:Number;
			           var z:Number;
			           
			           m.dxdx=plane[i].a;m.dxdy=plane[i].b;m.dxdz=plane[i].c;        
			           m.dydx=plane[j].a;m.dydy=plane[j].b;m.dydz=plane[j].c;        
			           m.dzdx=plane[k].a;m.dzdy=plane[k].b;m.dzdz=plane[k].c;
			           
			           var det:Number = m.det();
			           
			           if(det!=0) {
			           	
			              m.dxdx=-plane[i].d;m.dxdy=plane[i].b;m.dxdz=plane[i].c;        
			              m.dydx=-plane[j].d;m.dydy=plane[j].b;m.dydz=plane[j].c;        
			              m.dzdx=-plane[k].d;m.dzdy=plane[k].b;m.dzdz=plane[k].c;
			              
			              x=m.det()/det;
			
			              m.dxdx=plane[i].a;m.dxdy=-plane[i].d;m.dxdz=plane[i].c;        
			              m.dydx=plane[j].a;m.dydy=-plane[j].d;m.dydz=plane[j].c;        
			              m.dzdx=plane[k].a;m.dzdy=-plane[k].d;m.dzdz=plane[k].c;
			              
			              y=m.det()/det;
			
			              m.dxdx=plane[i].a;m.dxdy=plane[i].b;m.dxdz=-plane[i].d;        
			              m.dydx=plane[j].a;m.dydy=plane[j].b;m.dydz=-plane[j].d;        
			              m.dzdx=plane[k].a;m.dzdy=plane[k].b;m.dzdz=-plane[k].d;
			  
			              z=m.det()/det;
			              
			              points[p].x=x; points[p].y=y; points[p].z=z;
			              
						}else{
			           	
							points[p].x=0.0; points[p].y=0.0; points[p].z=0.0;
						}
			           
						++p;         
		        	}//END "for(k=4;k<6;k++)"           
		}
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	class CalCoreMaterial
	{
		public function CalCoreMaterial():void{
			super();
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalCoreSubmesh
	{
		private var m_vectorVertex:Array; // vertex
		private var m_vectorTangentsEnabled:Array; //booleans
		private var m_vectorvectorTangentSpace:Array; // tangent space
		private var m_vectorvectorTextureCoordinate:Array; //Texture Coord
		private var m_vectorPhysicalProperty:Array; // Physical Property
		private var m_vectorFace:Array;//Face
		private var m_vectorSpring:Array; //Spring
		private var m_vectorCoreSubMorphTarget:Array;//CalCoreSubMorphTarget
		private var m_coreMaterialThreadId:int
		private var m_lodCount:int;

		public function CalCoreSubmesh(vertexCount:int = 0, textureCoordinateCount:int = 0, faceCount:int = 0, springCount:int = 0):void{
			//trace("CalCoreSubmesh::CalCoreSubmesh -- " + vertexCount + " " + textureCoordinateCount + " " + faceCount + " " + springCount);
			m_vectorCoreSubMorphTarget = new Array();
			m_vectorSpring = new Array(springCount);
			m_vectorFace = new Array(faceCount);
			m_vectorvectorTextureCoordinate = new Array(textureCoordinateCount);
			m_vectorvectorTangentSpace = new Array();
			m_vectorTangentsEnabled = new Array();
			m_vectorVertex = new Array(vertexCount);
			m_vectorPhysicalProperty = new Array();
		}
		/*****************************************************************************
		* Returns the ID of the core material thread.
		*
		* This function returns the ID of the core material thread of this core
		* submesh instance.
		*
		* @return The ID of the core material thread.
		*****************************************************************************/
		public function getCoreMaterialThreadId():int {
			return m_coreMaterialThreadId;
		}
		
 		public function getFaceCount():int {
 			return m_vectorFace.length;
 		}
 		
		public function getLodCount():int {
			return m_lodCount;
		}
		
 		public function getSpringCount():int {
 			return m_vectorSpring.length;
 		}
 		
		public function getVectorFace():Array {
			return m_vectorFace;
		}
		
		public function getVectorPhysicalProperty():Array {
			return m_vectorPhysicalProperty;
		}
		
 		public function getVectorSpring():Array {
 			 return m_vectorSpring;
 		}
 		
		public function getVectorVectorTangentSpace():Array {
			return m_vectorvectorTangentSpace;
  	
  		}
  		
		public function getVectorVectorTextureCoordinate():Array {
			return m_vectorvectorTextureCoordinate;
		}
		
		public function getVectorVertex():Array {
			 return m_vectorVertex;
		}
		
 		public function getVertexCount():int {
 			return m_vectorVertex.length;
 		}

		/*****************************************************************************
		* Returns true if tangent vectors are enabled.
		*
  		* This function returns true if the core submesh contains tangent vectors.
  		*
  		* @return True if tangent vectors are enabled.
  		*****************************************************************************/ 		
		public function isTangentsEnabled( mapId:int ):Boolean {
			
			if( (mapId < 0) || (mapId >= m_vectorTangentsEnabled.length) )
				return false;
			return m_vectorTangentsEnabled[mapId];
		}
		
		public function enableTangents( mapId:int , enabled:Boolean ):Boolean {
/*
			if((mapId < 0) || (mapId >= (int)m_vectorTangentsEnabled.size())) return false;
  
  m_vectorTangentsEnabled[mapId] = enabled;

  if(!enabled)
  {
    m_vectorvectorTangentSpace[mapId].clear();
    return true;
  }

  m_vectorvectorTangentSpace[mapId].reserve(m_vectorVertex.size());
  m_vectorvectorTangentSpace[mapId].resize(m_vectorVertex.size());

  int tangentId;
  for(tangentId=0;tangentId< (int)m_vectorvectorTangentSpace[mapId].size();tangentId++)
  {
    m_vectorvectorTangentSpace[mapId][tangentId].tangent= CalVector(0.0f,0.0f,0.0f);
    m_vectorvectorTangentSpace[mapId][tangentId].crossFactor=1;

  }


  int faceId;
  for(faceId=0;faceId<(int)m_vectorFace.size();faceId++)
  {
    UpdateTangentVector(m_vectorFace[faceId].vertexId[0],m_vectorFace[faceId].vertexId[1],m_vectorFace[faceId].vertexId[2],mapId);
    UpdateTangentVector(m_vectorFace[faceId].vertexId[1],m_vectorFace[faceId].vertexId[2],m_vectorFace[faceId].vertexId[0],mapId);
    UpdateTangentVector(m_vectorFace[faceId].vertexId[2],m_vectorFace[faceId].vertexId[0],m_vectorFace[faceId].vertexId[1],mapId);
  }

  for(tangentId=0;tangentId< (int)m_vectorvectorTangentSpace[mapId].size();tangentId++)
  {
    m_vectorvectorTangentSpace[mapId][tangentId].tangent.normalize();
  }
*/  
  return true;

		}
		
		public function reserve( vertexCount:int, textureCoordinateCount:int, faceCount:int, springCount:int): Boolean {
			return true;
		}
		
		public function setCoreMaterialThreadId( coreMaterialThreadId:int ):void {
			
		}

		/*****************************************************************************
		* Sets a specified face.
  		*
  		* This function sets a specified face in the core submesh instance.
  		*
  		* @param faceId  The ID of the face.
  		* @param face The face that should be set.
  		*
  		* @return One of the following values:
  		*         \li \b true if successful
  		*         \li \b false if an error happend
  		*****************************************************************************/		
		public function setFace( faceId:int, face:Face ):Boolean {
			//trace("CalCoreSubmesh::setFace --  " + faceId + " " + face);
			if((faceId < 0) || (faceId >= m_vectorFace.length)) return false;
		
			m_vectorFace[faceId] = face;
			//trace("added: " + m_vectorFace[faceId]);
			return true;
		}

 		/*****************************************************************************
		* Sets the number of LOD steps.
		*
		* This function sets the number of LOD steps of the core submesh instance.
		*
		* @param lodCount The number of LOD steps that should be set.
	  	*****************************************************************************/		
		public function setLodCount( lodCount:int ):void {
			m_lodCount = lodCount;
		}
	
		/*****************************************************************************
		* Sets a specified physical property.
  		*
  		* This function sets a specified physical property in the core submesh
  		* instance.
  		*
  		* @param vertexId  The ID of the vertex.
  		* @param physicalProperty The physical property that should be set.
  		*
  		* @return One of the following values:
  		*         \li \b true if successful
  		*         \li \b false if an error happend
  		*****************************************************************************/		
		public function setPhysicalProperty( vertexId:int , physicalProperty:PhysicalProperty ):Boolean {
			
			 if((vertexId < 0) || (vertexId >= m_vectorPhysicalProperty.length)) return false;
			 	m_vectorPhysicalProperty[vertexId] = physicalProperty;
			return true;
		}

		/*****************************************************************************
		* Sets a specified spring.
  		*
  		* This function sets a specified spring in the core submesh instance.
  		*
  		* @param springId  The ID of the spring.
  		* @param spring The spring that should be set.
  		*
  		* @return One of the following values:
  		*         \li \b true if successful
  		*         \li \b false if an error happend
  		*****************************************************************************/		
 		public function setSpring( springId:int, spring:Spring ):Boolean {
 			
 			if((springId < 0) || (springId >= m_vectorSpring.length)) return false;
				m_vectorSpring[springId] = spring;
			return true;
 		}
 
		/*****************************************************************************
		* Sets the tangent vector associated with a specified texture coordinate pair.
		*
		* This function sets the tangent vector associated with a specified
		* texture coordinate pair in the core submesh instance.
		*
		* @param vertexId  The ID of the vertex.
		* @param textureCoordinateId The ID of the texture coordinate channel.
		* @param tangent   The tangent vector that should be stored.
		* @param crossFactor The cross-product factor that should be stored.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function setTangentSpace( vertexId:int, textureCoordinateId:int, tangent:CalVector, crossFactor:Number ):Boolean {
			
			if((vertexId < 0) || (vertexId >= m_vectorVertex.length)) return false;
			if((textureCoordinateId < 0) || (textureCoordinateId >= m_vectorvectorTextureCoordinate.length)) return false;
			if(!m_vectorTangentsEnabled[textureCoordinateId]) return false;
  
			m_vectorvectorTangentSpace[textureCoordinateId][vertexId].tangent = tangent;
			m_vectorvectorTangentSpace[textureCoordinateId][vertexId].crossFactor = crossFactor;
			return true;
		}

 		/*****************************************************************************
 		* Sets a specified texture coordinate.
		*
		* This function sets a specified texture coordinate in the core submesh
		* instance.
		*
		* @param vertexId  The ID of the vertex.
		* @param textureCoordinateId  The ID of the texture coordinate.
		* @param textureCoordinate The texture coordinate that should be set.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function setTextureCoordinate( vertexId:int, textureCoordinateId:int, textureCoordinate:TextureCoordinate ): Boolean {
			/*
			if((textureCoordinateId < 0) || (textureCoordinateId >= m_vectorvectorTextureCoordinate.length)) return false;
			if((vertexId < 0) || (vertexId >= m_vectorvectorTextureCoordinate[textureCoordinateId])) return false;
			trace("CalCoreSubmesh::setTextureCoordinate -- vertexId: " + vertexId + " textCoordId: " + textureCoordinateId
			m_vectorvectorTextureCoordinate[textureCoordinateId][vertexId] = textureCoordinate;
				*/
			return true;
		
		}

 		/*****************************************************************************
		* Sets a specified vertex.
 		*
  		* This function sets a specified vertex in the core submesh instance.
  		*
  		* @param vertexId  The ID of the vertex.
  		* @param vertex The vertex that should be set.
  		*
  		* @return One of the following values:
  		*         \li \b true if successful
  		*         \li \b false if an error happend
  		*****************************************************************************/		
		public function setVertex( vertexId:int , vertex:Vertex ):Boolean {
			
			//trace("CalCoreSubmesh::setVertex -- vertexId: " + vertexId + " " + vertex);
			if((vertexId < 0) || (vertexId >= m_vectorVertex.length)) return false;
			m_vectorVertex[vertexId] = vertex;
			//trace("index item: " + m_vectorVertex[vertexId]);
			return true;
		}
		
		public function addCoreSubMorphTarget( pCoreSubMorphTarget:CalCoreSubMorphTarget ):int {
			 
			 // get next sub morph target id
			var subMorphTargetId:int = m_vectorCoreSubMorphTarget.length;
			
			m_vectorCoreSubMorphTarget.push(pCoreSubMorphTarget);

			return subMorphTargetId;
		}

 		/*****************************************************************************
		* Provides access to a core sub morph target.
 	 	*
  		* This function returns the core sub morph target with the given ID.
  		*
  		* @param id The ID of the core sub morph target that should be returned.
  		*
  		* @return One of the following values:
  		*         \li a pointer to the core sub morph target
  		*         \li \b 0 if an error happend
  		*****************************************************************************/		
		public function getCoreSubMorphTarget( id:int ):CalCoreSubMorphTarget {
			
			if((id < 0) || (id >= m_vectorCoreSubMorphTarget.length)) return null;

			return m_vectorCoreSubMorphTarget[id];
		}

 		/*****************************************************************************
		* Returns the number of core sub morph targets.
 		*
  		* This function returns the number of core sub morph targets in the core sub mesh
  		* instance.
  		*
  		* @return The number of core sub morph targets.
  		*****************************************************************************/		
		public function getCoreSubMorphTargetCount():int {
			return m_vectorCoreSubMorphTarget.length;
		}
		
		public function getVectorCoreSubMorphTarget():Array {
			return m_vectorCoreSubMorphTarget;
		}
		
		public function scale( factor:Number ):void {
			
			// rescale all vertices
			for(var vertexId:int = 0; vertexId < m_vectorVertex.length ; vertexId++) {
				m_vectorVertex[vertexId].position*=factor;		
			}

		/*
			if(!m_vectorSpring.empty()) {

		    // There is a problem when we resize and that there is
		    // a spring system, I was unable to solve this
		    // problem, so I disable the spring system
		    // if the scale are too big

			if( Math.abs(factor - 1.0) > 0.10) {
				m_vectorSpring.clear();
				m_vectorPhysicalProperty.clear();
			}
		*/

		}

		private function UpdateTangentVector( v0:int, v1:int, v2:int, mapId:int ):void {
			
			var vvtx:Array = getVectorVertex(); //Vertex
			var vtex:Array = m_vectorvectorTextureCoordinate[mapId]; //TextureCoordinate

			// Step 1. Compute the approximate tangent vector.
			var du1:Number = vtex[v1].u - vtex[v0].u;
			var dv1:Number = vtex[v1].v - vtex[v0].v;
			var du2:Number = vtex[v2].u - vtex[v0].u;
			var dv2:Number = vtex[v2].v - vtex[v0].v;

			var prod1:Number = (du1*dv2-dv1*du2);
			var prod2:Number = (du2*dv1-dv2*du1);
			if ((Math.abs(prod1) < 0.000001)||(Math.abs(prod2) < 0.000001)) return;

			var x:Number = dv2/prod1;
			var y:Number = dv1/prod2;

 			var vec1:CalVector = vvtx[v1].position.subtract( vvtx[v0].position );
 			var vec2:CalVector = vvtx[v2].position.subtract( vvtx[v0].position );
 			vec1.multipyByFloat(x);
 			vec2.multipyByFloat(y); 
			var tangent:CalVector = vec1;
			tangent.add(vec2);
			
			// Step 2. Orthonormalize the tangent.
			var component:Number = (tangent.multiplyByVector( vvtx[v0].normal) );
			tangent.subtract( vvtx[v0].normal.multiplyByFloat(component) );
			tangent.normalize();

  			// Step 3: Add the estimated tangent to the overall estimate for the vertex.
			m_vectorvectorTangentSpace[mapId][v0].tangent.add(tangent);

		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	class CalCoreMesh
	{
		private var m_vectorCoreSubmesh:Array;
		private var m_name:String;
		private var m_filename:String;
		
		public function CalCoreMesh():void {
			m_vectorCoreSubmesh = new Array();
		}

		/*****************************************************************************
		* Adds a core submesh.
		*
		* This function adds a core submesh to the core mesh instance.
		*
		* @param pCoreSubmesh A pointer to the core submesh that should be added.
		*
		* @return One of the following values:
		*         \li the assigned submesh \b ID of the added core submesh
		*         \li \b -1 if an error happend
		*****************************************************************************/
		public function addCoreSubmesh( coreSubmesh:CalCoreSubmesh ):int {
			
			// get next bone id
			var submeshId:int = m_vectorCoreSubmesh.length;

			m_vectorCoreSubmesh.push(coreSubmesh);

			return submeshId;
		}

		/*****************************************************************************
		* Provides access to a core submesh.
		*
		* This function returns the core submesh with the given ID.
		*
		* @param id The ID of the core submesh that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the core submesh
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getCoreSubmesh( id:int ):CalCoreSubmesh {
			
			if((id < 0) || (id >= m_vectorCoreSubmesh.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return null;
			}

			return m_vectorCoreSubmesh[id];
   	
		}

		/*****************************************************************************
		* Returns the number of core submeshes.
		*
		* This function returns the number of core submeshes in the core mesh
		* instance.
		*
		* @return The number of core submeshes.
		*****************************************************************************/		
		public function getCoreSubmeshCount():int {
			return m_vectorCoreSubmesh.length;
		}

		/*****************************************************************************
		* Returns the core submesh vector.
		*
		* This function returns the vector that contains all core submeshes of the
		* core mesh instance.
		*
		* @return A reference to the core submesh vector.
		*****************************************************************************/
		public function getVectorCoreSubmesh():Array {
			return m_vectorCoreSubmesh;
		}

		/*****************************************************************************
		* Adds a core submesh.
		*
		* This function adds a core mesh as a blend target.
		* It adds appropriate CalCoreSubMorphTargets to each of the core sub meshes.
		*
		* @param pCoreMesh A pointer to the core mesh that shoulb become a blend target.
		*
		* @return One of the following values:
		*         \li the assigned morph target \b ID of the added blend target
		*         \li \b -1 if an error happend
		*****************************************************************************/		
		public function addAsMorphTarget( pCoreMesh:CalCoreMesh ):int {
			return -1;
		}

		/*****************************************************************************
		* Scale the Mesh.
		*
		* This function rescale all the data that are in the core mesh instance.
		*
		* @param factor A float with the scale factor
		*
		*****************************************************************************/		
		public function scale( factor:Number ):void {
			
			for each(var subMesh:CalCoreSubmesh in m_vectorCoreSubmesh){
				subMesh.scale(factor);    
			}
		}

		/*****************************************************************************
		* 
		* Set the name of the file in which the core mesh is stored, if any.
		*
		* @param filename The path of the file.
		*****************************************************************************/
		public function setFilename(filename:String):void {
			m_filename = filename;
		}

		/*****************************************************************************
		* 
		* Get the name of the file in which the core mesh is stored, if any.
		*
		* @return One of the following values:
		*         \li \b empty string if the mesh was not stored in a file
		*         \li \b the path of the file
		*
		*****************************************************************************/		
		public function getFilename():String {
  			return m_filename;
		}

		/*****************************************************************************
		* 
		* Set the symbolic name of the core mesh.
		*
		* @param name A symbolic name.
		*****************************************************************************/		
		public function setName( name:String ):void {
			m_name = name;
		}

		/*****************************************************************************
		* 
		* Get the symbolic name the core mesh.
		*
		* @return One of the following values:
		*         \li \b empty string if the mesh was no associated to a symbolic name
		*         \li \b the symbolic name
		*
		*****************************************************************************/		
		public function getName():String {
  			return m_name;
		}


	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	//import cal3d.datatypes.*;
	
	class CalCoreBone
	{
		
		private var m_strName:String;
  		private var m_pCoreSkeleton:CalCoreSkeleton;
		private var m_parentId:int;
  		private var m_listChildId:Array;//Collection;
		private var m_translation:CalVector;
		private var m_rotation:CalQuaternion;
		private var m_translationAbsolute:CalVector;
		private var m_rotationAbsolute:CalQuaternion;
		private var m_translationBoneSpace:CalVector;
		private var m_rotationBoneSpace:CalQuaternion;
  		//Cal::UserData m_userData;

		private var m_boundingBox:CalBoundingBox;
		private var m_boundingPosition:Array = new Array(6); //CalVector of [6];
		private var m_boundingBoxPrecomputed:Boolean;

		/*****************************************************************************
		* CONSTRUCTOR
		*
		* This function is the default constructor of the core bone instance.
		*
		* @param name	
		*****************************************************************************/		
		public function CalCoreBone( name:String ) {
			m_strName = name;
			m_listChildId = new Array;
			
			this.m_rotationAbsolute = new CalQuaternion();
			this.m_translationAbsolute = new CalVector();
		}
		
 		/*****************************************************************************
		* Adds a child ID.
		*
		* This function adds a core bone ID to the child ID list of the core bone
		* instance.
		*
		* @param childId The ID of the core bone ID that shoud be added to the child
		*                ID list.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function addChildId( childId:int ):Boolean{
		
			this.m_listChildId.push( childId );
			return true;
		}

 		/*****************************************************************************
		* Calculates the current state.
		*
		* This function calculates the current state (absolute translation and
		* rotation) of the core bone instance and all its children.
		*
		* @param void
		*
		* @return void
		*****************************************************************************/			
		public function calculateState():void {
		
			if(this.m_parentId == -1) {
				// no parent, this means absolute state == relative state
				this.m_translationAbsolute = this.m_translation.clone();
				this.m_rotationAbsolute = this.m_rotation.clone();
				
				//this.m_translationAbsolute.setToVector(m_translation);
				//this.m_rotationAbsolute.setToQuaternion(m_rotation);
				
			}else{
				// get the parent bone
				var pParent:CalCoreBone ;
				pParent = this.m_pCoreSkeleton.getCoreBone(this.m_parentId);
				/*
				// transform relative state with the absolute state of the parent
				this.m_translationAbsolute = 
					CalVector.multiplyVectorByQuaternion(m_translation, pParent.rotationAbsolute);
							
				this.m_translationAbsolute.add( pParent.translationAbsolute );

				this.m_rotationAbsolute = m_rotation, pParent.rotationAbsolute
				//this.m_rotationAbsolute.setToQuaternion(m_rotation);//.clone();
				
				this.m_rotationAbsolute.multiplyByQuaternion( pParent.rotationAbsolute );
				*/
				
				// transform relative state with the absolute state of the parent
				//this.m_translationAbsolute = this.m_translation.clone();
				//this.m_translationAbsolute.setToVector(m_translation);
				//this.m_translationAbsolute.multiplyByQuaternion( pParent.rotationAbsolute );
				
				this.m_translationAbsolute = 
					CalVector.multiplyVectorByQuaternion(this.m_translation,pParent.rotationAbsolute);
				
				
				//trace("normal: " + this.m_translationAbsolute);
				//var test:CalVector = CalVector.multiplyVectorByQuaternion(m_translation, pParent.rotationAbsolute);
				//trace("static: " + test);
				
				this.m_translationAbsolute.add( pParent.translationAbsolute );

				//this.m_rotationAbsolute = m_rotation.clone();
				//this.m_rotationAbsolute.setToQuaternion(m_rotation);//.clone();
				
				this.m_rotationAbsolute =
					CalQuaternion.multiplyQuaternions(m_rotationAbsolute, pParent.rotationAbsolute);
				//this.m_rotationAbsolute.multiplyByQuaternion( pParent.rotationAbsolute );
				
			}

			// calculate all child bones
			for each(var i:int in this.m_listChildId) {
				m_pCoreSkeleton.getCoreBone(i).calculateState();
			}

		}

 		/*****************************************************************************
		* Returns the child ID list.
		*
		* This function returns the list that contains all child IDs of the core bone
		* instance.
		*
		* @param void
		*
		* @return A reference to the child ID list.
		*****************************************************************************/	 
  		public function getListChildId():Array {
  			return this.m_listChildId;
  		}

		/*****************************************************************************
		* Returns the name.
		*
		* This function returns the name of the core bone instance.
		*
		* @return The name as string.
		*****************************************************************************/  
		public function get name():String {
			return m_strName;
		}

		/*****************************************************************************
		* Returns the parent ID.
		*
		* This function returns the parent ID of the core bone instance.
		*
		* @return One of the following values:
		*         \li the \b ID of the parent
		*         \li \b -1 if the core bone instance is a root core bone
		*****************************************************************************/		
		public function get parentId():int {
			return m_parentId;	
		}

		/*****************************************************************************
		* Provides access to the core skeleton.
		*
		* This function returns the core skeleton.
		*
		* @return One of the following values:
 		*         \li a pointer to the core skeleton
		*         \li \b 0 if an error happend
		*****************************************************************************/  		
		public function get coreSkeleton():CalCoreSkeleton{
			return m_pCoreSkeleton;
		}

		/*****************************************************************************
		* Sets the rotation.
		*
		* This function sets the relative rotation of the core bone instance.
		*
		* @param rotation The relative rotation to the parent as quaternion.
		*****************************************************************************/  		
		public function get rotation():CalQuaternion {
			return m_rotation;
		}		 
		
		public function get rotationAbsolute():CalQuaternion {
			return m_rotationAbsolute;
		}
		
		public function get rotationBoneSpace():CalQuaternion {
			return m_rotationBoneSpace;
		}
		
		public function get translation():CalVector {
			return m_translation;
		}
		
		public function get translationAbsolute():CalVector {
			return m_translationAbsolute;
		}
		
		public function get translationBoneSpace():CalVector {
			return m_translationBoneSpace;
		}

		//Cal::UserData getUserData();
		
		public function set coreSkeleton( pCoreSkeleton:CalCoreSkeleton ):void {
			 m_pCoreSkeleton = pCoreSkeleton;
		}
		
		public function set parentId( parentId:int ):void {
			m_parentId = parentId;
		}
  
		public function set rotation( rotation:CalQuaternion ):void {
			m_rotation = rotation;
		}
		
		public function set rotationBoneSpace( rotation:CalQuaternion ):void {
			m_rotationBoneSpace = rotation;
		}
  
		/*****************************************************************************
		* Sets the translation.
		*
		* This function sets the relative translation of the core bone instance.
		*
		* @param translation The relative translation to the parent as vector.
		*****************************************************************************/
		public function set translation( translation:CalVector ):void {
			m_translation = translation;
		}

		/*****************************************************************************
		* Sets the bone space translation.
		*
		* This function sets the translation that brings a point into the core bone
		* instance space.
		*
		* @param translation The translation that brings a point into bone space.
		*****************************************************************************/		
		public function set translationBoneSpace( translation:CalVector ):void {
			m_translationBoneSpace = translation;
		}
  
		//void setUserData(Cal::UserData userData);
		/*****************************************************************************
		* Calculates the bounding box.
		*
		* This function Calculates the bounding box of the core bone instance.
		*
		* @param pCoreModel The coreModel (needed for vertices data.
		*****************************************************************************/
		public function calculateBoundingBox( pCoreModel:CalCoreModel ):void {
		/*
			var boneId:int =  m_pCoreSkeleton.getCoreBoneId(m_strName);
			var bBoundsComputed:Boolean = false;
			var planeId:int;
	   
			var rot:CalQuaternion;
			rot = m_rotationBoneSpace;   
	
			rot.invert();
	   
			var dir:CalVector = new CalVector(1.0, 0.0, 0.0);
			dir.multiplyByQuaternion(rot);
			m_boundingBox.plane[0].setNormal(dir);
	
			dir = new CalVector(-1.0, 0.0, 0.0);
			dir.multiplyByQuaternion(rot);
			m_boundingBox.plane[1].setNormal(dir);
	
			dir = new CalVector(0.0, 1.0, 0.0);
			dir.multiplyByQuaternion(rot);
			m_boundingBox.plane[2].setNormal(dir);
	
			dir = new CalVector(0.0,-1.0, 0.0);
			dir.multiplyByQuaternion(rot);
			m_boundingBox.plane[3].setNormal(dir);
	
			dir = new CalVector(0.0, 0.0, 1.0);
			dir.multiplyByQuaternion(rot);
			m_boundingBox.plane[4].setNormal(dir);
	
			dir = new CalVector(0.0, 0.0, -1.0);
			dir.multiplyByQuaternion(rot);
			m_boundingBox.plane[5].setNormal(dir);
	   
			var meshId:int;
			for(meshId = 0; meshId < pCoreModel.getCoreMeshCount(); ++meshId) {
				CalCoreMesh * pCoreMesh = pCoreModel.getCoreMesh(meshId);
			   
				var submeshId:int;
				for(submeshId=0; submeshId<pCoreMesh.getCoreSubmeshCount(); submeshId++) {
		       	
				   var pCoreSubmesh:CalCoreSubmesh = pCoreMesh.getCoreSubmesh(submeshId);
				   
				   if(pCoreSubmesh.getSpringCount() == 0) {
					   
					   std::vector<CalCoreSubmesh::Vertex>& vectorVertex =  pCoreSubmesh.getVectorVertex();
					   for(size_t vertexId=0;vertexId <vectorVertex.size(); ++vertexId) {
					   	
						   for(size_t influenceId=0;influenceId<vectorVertex[vertexId].vectorInfluence.size();++influenceId) {
						   	
							   if(vectorVertex[vertexId].vectorInfluence[influenceId].boneId == boneId && vectorVertex[vertexId].vectorInfluence[influenceId].weight > 0.5) {						   
								   
								   for(planeId = 0; planeId < 6; ++planeId) {
								   	
									   if(m_boundingBox.plane[planeId].eval(vectorVertex[vertexId].position) < 0.0) {
										   m_boundingBox.plane[planeId].setPosition(vectorVertex[vertexId].position);
										   m_boundingPosition[planeId]=vectorVertex[vertexId].position;
										   bBoundsComputed=true;
									   }//END boundingbox
								   }//END planeId
							   }//END vectorVertex
						   }
					   }	
				   }
				}
			}
	
			// To handle bones with no vertices assigned 
			if(!bBoundsComputed) {
		   	 
				for(planeId = 0; planeId < 6; ++planeId) {
			   	 
					m_boundingBox.plane[planeId].setPosition(m_translation); 
					m_boundingPosition[planeId] = m_translation; 
				} 
			} 
		   
			m_boundingBoxPrecomputed = true;
		*/	
		}
  
  		public function getBoundingBox():CalBoundingBox {
  			
  			return m_boundingBox;
  		}
  		
		public function getBoundingData( planeId:int, position:CalVector ):void {
			
  			position = m_boundingPosition[planeId];
  		}
  		 
		public function isBoundingBoxPrecomputed():Boolean {
			
			return m_boundingBoxPrecomputed;
		}
  
		public function scale( factor:Number ):void {

			m_translation.multipyByFloat(factor);
			m_translationAbsolute.multipyByFloat(factor);
			m_translationBoneSpace.multipyByFloat(factor);
	
			// calculate all child bones
			for each(var i:int in this.m_listChildId) {
				m_pCoreSkeleton.getCoreBone(i).scale(factor);
			}
			
		}


		

		
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
 import de.polygonal.ds.*;
 
class CalCoreSkeleton
	{
		private var m_vectorCoreBone:Array;
		private var m_vectorRootCoreBoneId:Array;
		private var m_mapCoreBoneNames:HashMap;

  
		public function CalCoreSkeleton():void {
		
			m_vectorCoreBone = new Array();
			m_vectorRootCoreBoneId = new Array();
			m_mapCoreBoneNames = new HashMap();
			
		}

		/*****************************************************************************
		* Adds a core bone.
		*
		* This function adds a core bone to the core skeleton instance.
		*
		* @param pCoreBone A pointer to the core bone that should be added.
		* @return One of the following values:
		*		\li the assigned bone \b ID of the added core bone
		*       \li \b -1 if an error happend
		*****************************************************************************/		
		public function addCoreBone( pCoreBone:CalCoreBone ):int{

			// get next bone id
			var boneId:int;
			boneId = m_vectorCoreBone.length;
	
			m_vectorCoreBone.push(pCoreBone);
	
			// if necessary, add the core bone to the root bone list
			if(pCoreBone.parentId == -1) {
				//m_vectorRootCoreBoneId.push_back(boneId);
				m_vectorRootCoreBoneId.push(boneId);
			}
	
			// add a reference from the bone's name to its id
			mapCoreBoneName( boneId, pCoreBone.name );
	
			//trace("CalCoreSkeleton::addCoreBone -- translation " +  pCoreBone.translation);
	
			return boneId;
		}

		/*****************************************************************************
		* Calculates the current state.
		*
		* This function calculates the current state of the core skeleton instance by
		* calculating all the core bone states.
		* 
		* @param void
		* @return void
		*****************************************************************************/			
		public function calculateState():void {
			
			// calculate all bone states of the skeleton
			for each(var bone:CalCoreBone in this.m_vectorCoreBone ) {
    			bone.calculateState();
			}
		
		}
  
 		/*****************************************************************************
		* Provides access to a core bone.
		*
		* This function returns the core bone with the given ID.
		*
		* @param coreBoneId The ID of the core bone that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the core bone
		*         \li \b 0 if an error happend
		*****************************************************************************/
		public function getCoreBone( coreBoneId:int ):CalCoreBone {
			
			if((coreBoneId < 0) || (coreBoneId >= m_vectorCoreBone.length) ) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return null;
			}
			return m_vectorCoreBone[coreBoneId];			
		}		

		/*****************************************************************************
		* Provides access to a core bone.
		*
		* This function returns the core bone with the given name.
		*
		* @param strName The name of the core bone that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the core bone
		*         \li \b 0 if an error happend
		*****************************************************************************/
		public function getCoreBoneByName( name:String ):CalCoreBone {
			
			return getCoreBone( getCoreBoneId(name) );
		}
  
		/*****************************************************************************
		* Returns the ID of a specified core bone.
		*
		* This function returns the ID of a specified core bone.
		*
		* @param strName The name of the core bone that should be returned.
		*
		* @return One of the following values:
		*         \li the \b ID of the core bone
		*         \li \b -1 if an error happend
		*****************************************************************************/
		public function getCoreBoneId( name:String ):int {
			
			//Check to make sure the mapping exists
			if( m_mapCoreBoneNames.isEmpty() ) {
    			//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
    			trace("CalCoreSkeleton::getCoreBoneId -- HashMap is empty");
				return -1;
			}

  			return m_mapCoreBoneNames.find(name);
		}
		
		/*****************************************************************************
		* Maps the name of a bone to a specific bone id
		*
		* This function returns true or false depending on whether the mapping
		* was successful or not. Note that it is possible to overwrite and existing
		* mapping and no error will be given.
		*
		* @param coreBoneId The id of the core bone to be associated with the name.
		* @param strName The name of the core bone that will be associated with the id.
		*
		* @return One of the following values:
		*         \li true if the mapping was successful
		*         \li false if an invalid ID was given
		*****************************************************************************/
		public function mapCoreBoneName( coreBoneId:int, name:String ):Boolean {
			
			//Make sure the ID given is a valid corebone ID number
			if ( (coreBoneId < 0) || (coreBoneId >= m_vectorCoreBone.length) ) {
				return false;
			}

			//Add the mapping or overwrite an existing mapping
			m_mapCoreBoneNames.insert( coreBoneId, name );
			
			return true;
			
		}
		
		/*****************************************************************************
		* Returns the core bone vector.
		*
		* This function returns the vector that contains all core bones of the core
		* skeleton instance.
		*
		* @return A reference to the core bone vector.
		*****************************************************************************/
		public function get vectorCoreBone():Array {
			
			return m_vectorCoreBone;
		}


		/*****************************************************************************
		* Returns the root core bone id list.
		*
		* This function returns the list that contains all root core bone IDs of the
		* core skeleton instance.
		*
		* @return A reference to the root core bone id list.
		*****************************************************************************/		
		public function get vectorRootCoreBoneId():Array {
			
			return m_vectorRootCoreBoneId;
		}
		
		/*****************************************************************************
		* Calculates bounding boxes.
		*
		* This function Calculates the bounding box of every bone in the core Skeleton.
		*
		* @param pCoreModel The coreModel (needed for vertices data).
		*****************************************************************************/
		public function calculateBoundingBoxes( pCoreModel:CalCoreModel ):void {
			
			for(var boneId:int = 0; boneId < m_vectorCoreBone.length; ++boneId) {
				m_vectorCoreBone[boneId].calculateBoundingBox(pCoreModel);
			}			
		}

 		/*****************************************************************************
		* Scale the core skeleton.
		*
		* This function rescale all the data that are in the core skeleton instance.
		*
		* @param factor A float with the scale factor
		*****************************************************************************/		
  		public function scale( factor:Number ):void {
			
			for each(var bone:CalCoreBone in this.m_vectorCoreBone){
				bone.scale(factor);
			}
  		}
  		

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */


	
	class CalCoreModel extends EventDispatcher
	{
		
		private var m_strName:String;
		private var m_pCoreSkeleton:CalCoreSkeleton;
		private var m_vectorCoreAnimation:Array;
		private var m_vectorCoreMorphAnimation:Array;
		private var m_vectorCoreMesh:Array;
		private var m_vectorCoreMaterial:Array;
 		private var m_mapmapCoreMaterialThread:HashMap; //td::map<int, std::map<int, int> >
		private var m_userData:Object;
		private var m_animationName:HashMap; //std::map<std::string, int>
		private var m_materialName:HashMap; //std::map<std::string, int>
		private var m_meshName:HashMap; //  std::map<std::string, int>

		
		public function CalCoreModel( name:String="Model" ):void {
			this.m_strName = name;
			this.m_vectorCoreAnimation = new Array();
			this.m_vectorCoreMorphAnimation = new Array();
			this.m_vectorCoreMesh = new Array();
			this.m_vectorCoreMaterial = new Array();
			this.m_animationName = new HashMap();
		}
		
		public function getUserData():Object {
			return m_userData;
		}
		
		public function setUserData( userData:Object ):void {
			m_userData = userData;
		}

		/*****************************************************************************
		* Scale the core model.
		*
		* This function rescale all data that are in the core model instance
		*
		* @param factor A float with the scale factor
		*
		*****************************************************************************/
		public function scale( factor:Number ):void {
			  
			m_pCoreSkeleton.scale(factor);
			/*
			for(size_t animationId = 0; animationId < m_vectorCoreAnimation.size(); animationId++) {
				m_vectorCoreAnimation[animationId]->scale(factor);
			}
			
			for(size_t meshId = 0; meshId < m_vectorCoreMesh.size(); meshId++) {
				m_vectorCoreMesh[meshId]->scale(factor);
			}
			*/
		}


		

		/****************************************************************************
		/ ANIMATIONS
		/****************************************************************************/
		
		/*****************************************************************************
		* Adds a core animation.
  		*
  		* This function adds a core animation to the core model instance.
  		*
  		* @param pCoreAnimation A pointer to the core animation that should be added.
  		*	
  		* @return \li the assigned animation \b ID of the added core animation
  		*****************************************************************************/
		public function addCoreAnimation( pCoreAnimation:CalCoreAnimation ):int {
			
			var animationId:int = m_vectorCoreAnimation.length;
  			m_vectorCoreAnimation.push(pCoreAnimation);
  			return animationId;
		}
		
		public function makemodel():CalModel {
			return new CalModel(this);
		}		
		
		
		public function addCoreAnimationAt( pCoreAnimation:CalCoreAnimation, id:int ):int {
			
			var animationId:int = m_vectorCoreAnimation.length;
			if(animationId < id){
				
				while(animationId < id){
					m_vectorCoreAnimation.push(null);
					animationId = m_vectorCoreAnimation.length;
				}
				
			}else if(animationId == id){
  				m_vectorCoreAnimation.push(pCoreAnimation);
  				return id;	
  			}
  			
  			m_vectorCoreAnimation[id] = pCoreAnimation;
  			
  			return id;
		}


 		/*****************************************************************************
		* Provides access to a core animation.
		*
		* This function returns the core animation with the given ID.
		*
		* @param coreAnimationId The ID of the core animation that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the core animation
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getCoreAnimation( coreAnimationId:int ):CalCoreAnimation {
			
			if((coreAnimationId < 0) || (coreAnimationId >= m_vectorCoreAnimation.length)) {
    			//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
    			trace("CalCoreModel::getCoreAnimation ERROR -- ID " + coreAnimationId + " doesn't exist in " + m_vectorCoreAnimation.length);
    			return null;
  			}

 	 		return m_vectorCoreAnimation[coreAnimationId];

		}
 
  		/*****************************************************************************
		* Returns the number of core animations.
		*
		* This function returns the number of core animations in the core model
		* instance.
		*
		* @return The number of core animations.
		*****************************************************************************/ 
		public function getCoreAnimationCount():int {
			return m_vectorCoreAnimation.length;
		}

		/*****************************************************************************
		* Loads a core animation.
		*
		* This function loads a core animation from a file.
		*
		* @param strFilename The file from which the core animation should be loaded
		*                    from.
		*
		* @return One of the following values:
		*         \li the assigned \b ID of the loaded core animation
		*         \li \b -1 if an error happend
		*****************************************************************************/
		public function loadCoreAnimation( filename:String ):void {

			var loader:CalLoader = new CalLoader();
			loader.addEventListener(CalEvent.ANIMATION_LOADED, animationComplete);
			loader.loadCoreAnimation(filename,m_pCoreSkeleton);

		}
		
		public function loadCoreAnimationById( filename:String, id:int ):void {

			var loader:CalLoader = new CalLoader();
			loader.addEventListener(CalEvent.ANIMATION_LOADED, animationComplete);
			loader.loadCoreAnimationById(filename,m_pCoreSkeleton, id);

		}
		
		
		public function unloadCoreAnimation( name:String ):int {
			return -1;
		}
  
		public function unloadCoreAnimationById( coreAnimationId:int ):int {
			return -1;
		}
  
		public function saveCoreAnimation( strFilename:String, coreAnimationId:int ):Boolean {
  			return false;
		}

 		/*****************************************************************************
		* Creates or overwrites a string-to-animation ID mapping
		*
		* This function makes an animation ID reference-able by a string name.
		* Note that we don't verify that the ID is valid because the animation
		* may be added later.
		* Also, if there is already a helper with this name, it will be overwritten
		* without warning.
		*
		* @param strAnimationName The string that will be associated with the ID.
		* @param coreAnimationId The ID number of the animation to be referenced by the string.
		*****************************************************************************/		
		public function addAnimationName( animationName:String, coreAnimationId:int ):Boolean {
		  	// check if the core animation id is valid
			if((coreAnimationId < 0) || (coreAnimationId >= m_vectorCoreAnimation.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				trace("CalCoreModel::addAnimationName ERROR -- Invalid Handle");
				return false;
			}

			m_vectorCoreAnimation[ coreAnimationId ].name = animationName;
			m_animationName.insert( animationName, coreAnimationId );
			return true;
			
		}

 		/*****************************************************************************
		* Retrieves the ID of the animation referenced by a string
		*
		* This function returns an animation ID
 		*
		* @param strAnimationName A string that is associated with an anim ID number.
		* @return Returns:
		*         \li \b -1 if there is no anim ID associated with the input string
		*         \li \b the ID number of the anim asssociated with the input string
		*****************************************************************************/		
		public function getCoreAnimationId( animationName:String ):int {
			
			if(m_animationName.containsKey(animationName) ){
				return int(m_animationName.find(animationName));
			}else return -1;
			
		}
		
		
		/****************************************************************************
		/ MORPH ANIMATIONS
		/****************************************************************************/		
		public function addCoreMorphAnimation( pCoreMorphAnimation:CalCoreMorphAnimation ):int {
			trace("$$$$$$$$ Adding Core Morph Animation $$$$$$$$$$$");
			// get the id of the core morph animation
			var morphAnimationId:int = m_vectorCoreMorphAnimation.length;
  			m_vectorCoreMorphAnimation.push(pCoreMorphAnimation);

  			return morphAnimationId;
		}


 		/*****************************************************************************
		* Provides access to a core morph animation.
		*
		* This function returns the core morph animation with the given ID.
		*
		* @param coreMorphAnimationId The ID of the core morph animation that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the core morph animation
		*         \li \b 0 if an error happend
		 *****************************************************************************/		
		public function getCoreMorphAnimation( coreMorphAnimationId:int ):CalCoreMorphAnimation {
			
			if((coreMorphAnimationId < 0) || (coreMorphAnimationId >= m_vectorCoreMorphAnimation.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
    			return null;
  			}

  			return m_vectorCoreMorphAnimation[coreMorphAnimationId];
			
		}
		
		/*****************************************************************************
		* Returns the number of core morph animations.
 		*
 		* This function returns the number of core morph animations in the core model
		* instance.
 		*
		* @return The number of core morph animations.
		*****************************************************************************/		
		public function getCoreMorphAnimationCount():int {
			return m_vectorCoreMorphAnimation.length;
		}


		/****************************************************************************
		/ MATERIALS
		/****************************************************************************/
		 
		public function addCoreMaterial( pCoreMaterial:CalCoreMaterial ):int {
			
			// get the id of the core material
			var materialId:int = m_vectorCoreMaterial.length;
			m_vectorCoreMaterial.push(pCoreMaterial);
			return materialId;
		}
		
		public function createCoreMaterialThread( coreMaterialThreadId:int ):Boolean {
			// insert an empty core material thread with a given id
  			//std::map<int, int> mapCoreMaterialThreadId;
  			//var 
			//m_mapmapCoreMaterialThread.insert(std::make_pair(coreMaterialThreadId, mapCoreMaterialThreadId));
			return true;
		}
		
		public function getCoreMaterial( coreMaterialId:int ):CalCoreMaterial {
			return null;
		}
		
		public function getCoreMaterialCount():int {
			  return m_vectorCoreMaterial.length;
		}
		
		public function getCoreMaterialId( coreMaterialThreadId:int, coreMaterialSetId:int):int {
			return -1;
		}
		public function loadCoreMaterialByName( filename:String ):int {
			return -1;
		}
		public function loadCoreMaterial( filename:String, materialName:String ):int {
			return -1;
		}
		public function unloadCoreMaterialByName( name:String ):int {
			return -1;
		}
		public function unloadCoreMaterial( coreMaterialId:int ):int {
			return -1;
		}
		public function saveCoreMaterial( filename:String, coreMaterialId:int ):Boolean {
			return true;
		}
		public function setCoreMaterialId( coreMaterialThreadId:int, coreMaterialSetId:int, coreMaterialId:int):Boolean {
			return true;
		}
		public function addMaterialName( materialName:String, coreMaterialId:int ):Boolean {
			return true;
		}
		public function getCoreMaterialIdByName( materialName:String ):int {
			return -1;
		}


		/****************************************************************************
		// MESHES
		/****************************************************************************/
		
		/*****************************************************************************
		* Adds a core mesh.
		*
		* This function adds a core mesh to the core model instance.
		*
		* @param pCoreMesh A pointer to the core mesh that should be added.
		*
		* @return One of the following values:
		*         \li the assigned mesh \b ID of the added core material
		*         \li \b -1 if an error happend
		*****************************************************************************/
		public function addCoreMesh( pCoreMesh:CalCoreMesh ):int {
			
			// get the id of the core mesh
			var meshId:int = m_vectorCoreMesh.length;
			m_vectorCoreMesh.push(pCoreMesh);
			return meshId;
		}
		
		/*****************************************************************************
		* Provides access to a core mesh.
		*
		* This function returns the core mesh with the given ID.
		*
		* @param coreMeshId The ID of the core mesh that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the core mesh
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getCoreMesh( coreMeshId:int ):CalCoreMesh {
			
			if((coreMeshId < 0) || (coreMeshId >= m_vectorCoreMesh.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return null;
			}

  			return m_vectorCoreMesh[coreMeshId];//.get();
		}
		
		/*****************************************************************************
		* Returns the number of core meshes.
		*
		* This function returns the number of core meshes in the core model instance.
		*
		* @return The number of core meshes.
		*****************************************************************************/		
 		public function getCoreMeshCount():int {
 			return m_vectorCoreMesh.length;
 		}
 
		/*****************************************************************************
		* Loads a core mesh.
		*
		* This function loads a core mesh from a file.
		*
		* @param strFilename The file from which the core mesh should be loaded from.
		*
		* @return One of the following values:
		*         \li the assigned \b ID of the loaded core mesh
		*         \li \b -1 if an error happend
		*****************************************************************************/		
		public function loadCoreMesh( filename:String ):void {

			// load a new core skeleton
			var loader:CalLoader = new CalLoader();
			loader.addEventListener(CalEvent.MESH_LOADED, meshComplete);
			loader.loadCoreMesh(filename);
			
		}
		
		
		public function loadCoreMeshByName( filename:String, meshName:String ):void {
					
			// load a new core skeleton
			var loader:CalLoader = new CalLoader();
			loader.addEventListener(CalEvent.MESH_LOADED, meshComplete);
			loader.loadCoreMeshByName(filename, meshName);		
	
		}

		/*****************************************************************************
		* Delete the resources used by the named core mesh. The name must 
		* be associated with a valid core mesh Id with the function
		* getMeshId. The caller must ensure that the corresponding is not
		* referenced anywhere otherwise unpredictable results will occur.
		*
		* @param name The symbolic name of the core mesh to unload.
		*
		* @return One of the following values:
 		*         \li the core \b ID of the unloaded core mesh
		*         \li \b -1 if an error happend
		*****************************************************************************/		
		public function unloadCoreMeshByName( name:String ):int {
			
			var id:int = getCoreMeshId(name);
			if(id >= 0) return unloadCoreMesh(id);
			else return -1;
		}
		
		public function unloadCoreMesh( coreMeshId:int ):int {
			  return -1;
		}
		
		public function saveCoreMesh( filename:String, coreMeshId:int):Boolean {
			  return true;
		}
		
		public function addMeshName( meshName:String, coreMeshId:int):Boolean {
			  return true;
		}
		
		public function getCoreMeshId( meshName:String ):int {
			  return -1;
		}



		// skeleton
		public function getCoreSkeleton():CalCoreSkeleton {
			 return m_pCoreSkeleton;
		}

		/*****************************************************************************
		* Loads the core skeleton.
		*
		* This function loads the core skeleton from a file.
		*
		* @param strFilename The file from which the core skeleton should be loaded
		*                    from.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function loadCoreSkeleton( filename:String ):void {
			
			// load a new core skeleton
			var loader:CalLoader = new CalLoader();
			loader.addEventListener(CalEvent.SKELETON_LOADED, skeletonComplete);
			loader.loadCoreSkeleton(filename);
		}

		private function meshComplete(event:CalEvent):void {
	
		 	addCoreMesh( CalCoreMesh(event.content) );
			trace("mesh loaded");
			this.dispatchEvent( new Event(Event.COMPLETE) );
			
		}
		
		private function skeletonComplete(event:CalEvent):void {
			
			m_pCoreSkeleton = CalCoreSkeleton(event.content);
			trace("skeleton loaded");
			this.dispatchEvent( new Event(Event.COMPLETE) );
		}
		
		private function animationComplete(event:CalEvent):void {
			
			//this.m_vectorCoreAnimation.push( CalCoreAnimation(event.content) );
			var animation:CalCoreAnimation = CalCoreAnimation(event.content);
			
			//animation.name = "test";
			var id:int;
			if(event.id != -1){
				id = addCoreAnimationAt(animation, event.id);
			}else{
				id = addCoreAnimation(animation); 
				
			}

			addAnimationName( "test" + id, id );
			
			trace("%%%%%%% animation  " + id + " loaded");
			this.dispatchEvent( new Event(Event.COMPLETE) );
		}
		

		/*****************************************************************************
		* Saves the core skeleton.
		*
		* This function saves the core skeleton to a file.
		*
		* @param strFilename The file to which the core skeleton should be saved to.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function saveCoreSkeleton( filename:String ):Boolean {
			/*
			// check if we have a core skeleton in this code model
			if(!m_pCoreSkeleton) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}

			// save the core skeleton
			return CalSaver::saveCoreSkeleton(strFilename, m_pCoreSkeleton.get());
			*/
			return false;
		}

		/*****************************************************************************
		* Sets the core skeleton.
		*
		* This function sets the core skeleton of the core model instance..
		*
		* @param pCoreSkeleton The core skeleton that should be set.
		*****************************************************************************/  
  		public function setCoreSkeleton( pCoreSkeleton:CalCoreSkeleton ):void {
  			  
			if(pCoreSkeleton==null) {
				print("Skeleton was null!!");
				return;
			}
  			m_pCoreSkeleton = pCoreSkeleton;
  		}
 
		/*****************************************************************************
		* Creates or overwrites a string-to-boneId mapping
		*
		* This function makes a bone ID reference-able by a string name.
		*
		* @param strBoneName The string that will be associated with the ID.
		* @param boneId The ID number of the bone that will be referenced by the string.
		*****************************************************************************/ 		
		public function addBoneName( boneName:String, boneId:int ):void {
			
			//Make sure the skeleton has been loaded first
			if (m_pCoreSkeleton) {
				//Map the bone ID to the name
				m_pCoreSkeleton.mapCoreBoneName(boneId, boneName);
			}
		}

		/*****************************************************************************
		* Retrieves the ID of the bone referenced by a string
		*
		* This function returns a bone ID
		*
		* @param strBoneName A string that is associated with a bone ID number.
		* @return Returns:
		*         \li \b -1 if there is no bone ID associated with the input string
		*         \li \b the ID number of the bone asssociated with the input string
		*****************************************************************************/		
		public function getBoneId( boneName:String ):int {
			
			if (m_pCoreSkeleton) {
				return m_pCoreSkeleton.getCoreBoneId(boneName);
  			}
 			return -1;
			
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

	
	class CalCoreSubMorphTarget
	{
		private var m_vectorBlendVertex:Array;

		public function CalCoreSubMorphTarget():void {
			m_vectorBlendVertex = new Array();
		}

		/*****************************************************************************
		* Returns the blend vertex vector.
		*
		* This function returns the vector that contains all blend vertices of the core
		* sub morph target instance.
		*
		* @return A reference to the blend vertex vector.
		*****************************************************************************/
		
		public function getBlendVertexCount():int {
			
			return m_vectorBlendVertex.length;
		}

		/*****************************************************************************
		* Returns the number of blend vertices.
		*
		* This function returns the number of blend vertices in the 
		* core sub morph target instance.
		*
 		* @return The number of blend vertices.
		*****************************************************************************/		
		public function getVectorBlendVertex():Array {
			return m_vectorBlendVertex;
		}

		/*****************************************************************************
		* Reserves memory for the blend vertices.
		*
		* This function reserves memory for the blend vertices
		 * of the core sub morph target instance.
		*
		* @param blendVertexCount The number of blend vertices that
		*                    this core sub morph target instance should be able to hold.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/
		public function reserve( blendVertexCount:int ):Boolean {
			return true;
		}

		/*****************************************************************************
		* Sets a specified blend vertex.
		*
		* This function sets a specified blend vertex in the core sub morph target instance.
		*
		* @param vertexId  The ID of the vertex.
		* @param vertex The vertex that should be set.
		*
		* @return One of the following values:
			*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function setBlendVertex( blendVertexId:int, blendVertex:BlendVertex ):Boolean {
			
			if((blendVertexId < 0) || (blendVertexId >= m_vectorBlendVertex.length )) return false;
			m_vectorBlendVertex[blendVertexId] = blendVertex;
			return true;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalAnimation
	{ 
		//fake enum types
		public static var TYPE_NONE:int = 0;
		public static var TYPE_CYCLE:int = 1;
		public static var TYPE_POSE:int = 2;
		public static var TYPE_ACTION:int = 3;
		
		//fake enum states
		public static var STATE_NONE:int = 0;
		public static var STATE_SYNC:int = 1;
		public static var STATE_ASYNC:int = 2;
		public static var STATE_IN:int = 3;
		public static var STATE_STEADY:int = 4;
		public static var STATE_OUT:int = 5;
		public static var STATE_STOPPED:int = 6;
		
		private var m_pCoreAnimation:CalCoreAnimation;
		private var m_lastCallbackTimes:Array;
		private var m_type:int;
		private var m_state:int;
		private var m_time:Number;
		private var m_timeFactor:Number;
		private var m_weight:Number;
		
		public function CalAnimation( pCoreAnimation:CalCoreAnimation ):void {

			if(pCoreAnimation == null) return;
			
			m_pCoreAnimation = pCoreAnimation;
			m_type = CalAnimation.TYPE_NONE;
			m_state = CalAnimation.STATE_NONE;
			m_time = 0.0;
			m_timeFactor = 1.0;
			m_weight = 0.0;
			
  			var callBackList:Array = m_pCoreAnimation.getCallbackList();
			for(var i:int = 0; i < callBackList.length; i++) {
				// build up the last called list
				m_lastCallbackTimes.push(0.0);  
			}
				
		}

		/*****************************************************************************
		* Provides access to the core animation.
		*
 		* This function returns the core animation on which this animation instance
		* is based on.
		*
		* @return One of the following values:
		*         \li a pointer to the core animation
		*         \li \b 0 if an error happend
		*****************************************************************************/
		public function getCoreAnimation():CalCoreAnimation {
			return m_pCoreAnimation;
		}

 		/*****************************************************************************
		* Returns the state.
		*
		* This function returns the state of the animation instance.
		*
		* @return One of the following states:
		*         \li \b STATE_NONE
		*         \li \b STATE_SYNC
		*         \li \b STATE_ASYNC
		*         \li \b STATE_IN
		*         \li \b STATE_STEADY
		*         \li \b STATE_OUT
		*****************************************************************************/
		public function getState():int {
			return m_state;
		}	

		/*****************************************************************************
		* Returns the time.
		*
		* This function returns the time of the animation instance.
		*
		* @return The time in seconds.
		*****************************************************************************/
		public function getTime():Number {
			return m_time;
		}

 		/*****************************************************************************
		* Returns the type.
		*
		* This function returns the type of the animation instance.
 		*
		* @return One of the following types:
		*         \li \b TYPE_NONE
		*         \li \b TYPE_CYCLE
		*         \li \b TYPE_POSE
		*         \li \b TYPE_ACTION
		*****************************************************************************/		
		public function getType():int {
			return m_type;
		}


		/*****************************************************************************
		* Returns the weight.
		*
		* This function returns the weight of the animation instance.
		*
		* @return The weight.
		*****************************************************************************/		
		public function getWeight():Number {
			return m_weight;
		}

		/*****************************************************************************
		* Set the time.
		*
  		* This function set the time of the animation instance.
		*
		*****************************************************************************/		
		public function setTime( time:Number ):void {
			 m_time = time;
		}

		/*****************************************************************************
		* Set the time factor.
		* 
		* This function sets the time factor of the animation instance.
		* this time factor affect only sync animation
		*
		*****************************************************************************/		
		public function setTimeFactor( timeFactor:Number ):void {
			m_timeFactor = timeFactor;
		}

		/*****************************************************************************
		* Get the time factor.
		* 
		* This function return the time factor of the animation instance.
		*
		*****************************************************************************/		
		public function getTimeFactor():Number {
			return m_timeFactor;
		}

		public function checkCallbacks( animationTime:Number, model:CalModel ):void {
			
			var list:Array = m_pCoreAnimation.getCallbackList();

			for(var i:int=0; i < list.length; i++) {
				// need these two lines to allow dynamic adding of callbacks. 
				if (m_lastCallbackTimes.length <= i)                
					m_lastCallbackTimes.push(animationTime);

				list[i].callback.AnimationUpdate( animationTime, model, model.getUserData() );
				
				if (animationTime > 0 && animationTime < m_lastCallbackTimes[i])  // looped
					m_lastCallbackTimes[i] -= m_pCoreAnimation.duration;
					
    			else if (animationTime < 0 && animationTime > m_lastCallbackTimes[i])     // reverse-looped  
					m_lastCallbackTimes[i] += m_pCoreAnimation.duration;
  
				if ((animationTime >= 0 && animationTime >= m_lastCallbackTimes[i] + list[i].min_interval) ||
        			(animationTime <  0 && animationTime <= m_lastCallbackTimes[i] - list[i].min_interval)) {
      
      				list[i].callback.AnimationUpdate(animationTime, model, model.getUserData());
      				m_lastCallbackTimes[i] = animationTime;
    			}
  			}
		}
		
		public function completeCallbacks( model:CalModel ):void {
			var list:Array = m_pCoreAnimation.getCallbackList();
			for (var i:int=0; i<list.length; i++)
				list[i].callback.AnimationComplete(model, model.getUserData());
		}

		protected function setType( type:int ):void {
			m_type = type;
		}

		protected function setState( state:int ):void {
			m_state = state;
		}

		protected function setWeight( weight:Number ):void {
			m_weight = weight;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalCoreMorphAnimation
	{
		
		private var m_vectorCoreMeshID:Array;
		private var m_vectorMorphTargetID:Array;
		
		public function CalCoreMorphAnimation(){
			m_vectorCoreMeshID = new Array();
			m_vectorMorphTargetID = new Array();
		}

		/*****************************************************************************
		* Adds a core mesh ID and a morph target ID of that core mesh.
		*
		* @param coreMeshID A core mesh ID that should be added.
		* @param morphTargetID A morph target ID that should be added.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/
		public function addMorphTarget( coreMeshID:int, morphTargetID:int):Boolean{
  			m_vectorCoreMeshID.push(coreMeshID);
			m_vectorMorphTargetID.push(morphTargetID);
  			return true;
  		}

		/*****************************************************************************
		* Returns the core mesh ID list.
		*
		* This function returns the list that contains all core mesh IDs of the core
 		* morph animation instance.
		*
		* @return A reference to the core mesh ID list.
		*****************************************************************************/
		public function getVectorCoreMeshID():Array {
			return m_vectorCoreMeshID;
		}


		/*****************************************************************************
		* Returns the morph target ID list.
 		*
  		* This function returns the list that contains all morph target  IDs of the core
  		* morph animation instance.
  		*
  		* @return A reference to the morph target ID list.
  		*****************************************************************************/		
		public function getVectorMorphTargetID():Array{
			return m_vectorMorphTargetID;
		}
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalCoreKeyframe
	{
		protected var m_time:Number
		protected var m_translation:CalVector;
		protected var m_rotation:CalQuaternion;

		public function CalCoreKeyframe():void {
			m_time = 0.0;		
		}

		/*****************************************************************************
		* Returns the rotation.
		*
		* This function returns the rotation of the core keyframe instance.
		*
		* @return The rotation as quaternion.
		*****************************************************************************/
		public function getRotation():CalQuaternion {
			return m_rotation;
		}

		/*****************************************************************************
		* Returns the time.
		*
		* This function returns the time of the core keyframe instance.
		*
		* @return The time in seconds.
		*****************************************************************************/
		public function getTime():Number {
			return m_time;
		}

		/*****************************************************************************
		* Returns the translation.
		*
		* This function returns the translation of the core keyframe instance.
		*
		* @return The translation as vector.
		*****************************************************************************/
		public function getTranslation():CalVector {
			return m_translation;
		}

		/*****************************************************************************
		* Sets the rotation.
		*
		* This function sets the rotation of the core keyframe instance.
		*
		* @param rotation The rotation as quaternion.
		*****************************************************************************/
		public function setRotation( rotation:CalQuaternion ):void {
			m_rotation = rotation;
		}

		/*****************************************************************************
		* Sets the time.
		*
		* This function sets the time of the core keyframe instance.
		*
		* @param rotation The time in seconds.
		*****************************************************************************/
		public function setTime( time:Number ):void {
			 m_time = time;
		}

		/*****************************************************************************
		* Sets the translation.
		*
		* This function sets the translation of the core keyframe instance.
		*
		* @param rotation The translation as vector.
		*****************************************************************************/
		public function setTranslation( translation:CalVector ):void {
			m_translation = translation;
		}


	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalCoreTrack
	{
		/// The index of the associated CoreBone in the CoreSkeleton.
		protected var m_coreBoneId:int
		/// List of keyframes, always sorted by time.
		//protected var m_keyframes:Array;
		protected var m_keyframes:DLinkedList;
		
		public function CalCoreTrack():void {
			super();
			m_keyframes = new DLinkedList();
			//m_keyframes = new Array();
		}
	
		/*****************************************************************************
	 	* Returns a specified state.
		*
		* This function returns the state (translation and rotation of the core bone)
		* for the specified time and duration.
		*
		* @param time The time in seconds at which the state should be returned.
		* @param translation A reference to the translation reference that will be
		*                    filled with the specified state.
		* @param rotation A reference to the rotation reference that will be filled
		*                 with the specified state.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/	
 		
		public function getState( time:Number, translation:CalVector , rotation:CalQuaternion ):Object {
			
			var iteratorCoreKeyframeBefore:DListIterator = m_keyframes.getListIterator();
			var beforeValue:*;
			var iteratorCoreKeyframeAfter:DListIterator = m_keyframes.getListIterator();
			var afterValue:*;
			
			// get the keyframe after the requested time
			var bound:int = getUpperBound(time);// + 1;
			
			for(var i:int = 0; i <= bound; i++){
				afterValue = iteratorCoreKeyframeAfter.next();
			}

  			for(var x:int = 0; x <= (bound - 1); x++){
				beforeValue = iteratorCoreKeyframeBefore.next();
			}
  			
	
  			// check if the time is after the last keyframe
  			if(iteratorCoreKeyframeAfter.data == m_keyframes.tail.data) {
    			// return the last keyframe state
    			iteratorCoreKeyframeAfter.back();
				afterValue = iteratorCoreKeyframeAfter.data;			
    			rotation = afterValue.getRotation().clone();
    			translation = afterValue.getTranslation();

   		 		return {t:translation, r:rotation};
  			}

  			// check if the time is before the first keyframe
  			if(iteratorCoreKeyframeAfter.data == m_keyframes.head.data) {
  				
				afterValue = iteratorCoreKeyframeAfter.data;
    			// return the first keyframe state
    			rotation = afterValue.getRotation().clone();
   				translation = afterValue.getTranslation().clone();
		    	
    			return {t:translation, r:rotation};
  			}

  			// get the two keyframe pointers
  			var pCoreKeyframeBefore:CalCoreKeyframe = beforeValue;
			var pCoreKeyframeAfter:CalCoreKeyframe = afterValue; 

			// calculate the blending factor between the two keyframe states	
  			var blendFactor:Number;
  			blendFactor = (time - pCoreKeyframeBefore.getTime()) / (pCoreKeyframeAfter.getTime() - pCoreKeyframeBefore.getTime());

			// blend between the two keyframes
  			translation = pCoreKeyframeBefore.getTranslation().clone();
  			rotation = pCoreKeyframeBefore.getRotation().clone();
  			
			translation.blend(blendFactor, pCoreKeyframeAfter.getTranslation());
  			rotation.blend(blendFactor, pCoreKeyframeAfter.getRotation());

  			return {t:translation, r:rotation};// true;
		}

		/*****************************************************************************
		* Returns the ID of the core bone.
		*
		* This function returns the ID of the core bone to which the core track
 		* instance is attached to.
		*
		* @return One of the following values:
 		*         \li the \b ID of the core bone
		*         \li \b -1 if an error happend
		*****************************************************************************/

		public function getCoreBoneId():int {
			return m_coreBoneId;
		}


		/*****************************************************************************
		* Sets the ID of the core bone.
		*
		* This function sets the ID of the core bone to which the core track instance
		* is attached to.
		*
		* @param coreBoneId The ID of the bone to which the core track instance should
		*                   be attached to.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/
		public function setCoreBoneId( coreBoneId:int ):Boolean {
			
			if(coreBoneId < 0) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}
			
			m_coreBoneId = coreBoneId;
			return true;
		}  


		public function getCoreKeyframeCount():int {
  			//return m_keyframes.length;
  			return m_keyframes.size;
		}

		public function getCoreKeyframe( idx:int ):CalCoreKeyframe {
			
			
			var getItr:DListIterator = m_keyframes.getListIterator();
			var count:int = 0;
			while(count != idx){
				getItr.next();
				count++;
			}
			
			return getItr.data;
			
			//return this.m_keyframes[idx];
			
		}

		public function addCoreKeyframe( pCoreKeyframe:CalCoreKeyframe ):Boolean {
			
			/*
			m_keyframes.push(pCoreKeyframe);
			var idx:int = m_keyframes.size - 1;
	
			while (idx > 0 && m_keyframes[idx].getTime() < m_keyframes[idx - 1].getTime()) {
				//std::swap(m_keyframes[idx], m_keyframes[idx - 1]);
				//swap values
				var swap:CalCoreKeyframe = m_keyframes[idx];
				m_keyframes[idx] = m_keyframes[idx - 1];
				m_keyframes[idx - 1] = swap;
    			--idx;
    		}
    		
  			return true;			
			*/
			
			m_keyframes.append(pCoreKeyframe);
			var idx:int = m_keyframes.size - 1;
			
			var timesync:Array = m_keyframes.toArray()
				
			while (idx > 0 && timesync[idx].getTime() < timesync[idx - 1].getTime()) {
				//std::swap(m_keyframes[idx], m_keyframes[idx - 1]);
				//swap values
				var swap:CalCoreKeyframe = timesync[idx];
				timesync[idx] = timesync[idx - 1];
				timesync[idx - 1] = swap;
    			--idx;
    		}
    		
    		m_keyframes = new DLinkedList;
    		for each(var keyframe:CalCoreKeyframe in timesync){
    			m_keyframes.append(keyframe);
    		}
    		
  			return true;
  			
		}
		
		public function removeCoreKeyFrame( i:int):void { 
			
			var removeItr:DListIterator = m_keyframes.getListIterator();
			var count:int = 0;
			while(count != i){
				removeItr.next();
				count++;
			}
			m_keyframes.remove(removeItr);
		}

		public function scale( factor:Number ):void {

		}

  		private function getUpperBound( time:Number ):int{
			
  			
  			var lowerBound:int = 0;
			var upperBound:int = m_keyframes.size - 1;
	
			var bounds:Array = m_keyframes.toArray();

			while(lowerBound < upperBound-1) {
				
				var middle:int = (lowerBound + upperBound)/2;
				
				if(time >= bounds[middle].getTime()) {
					lowerBound=middle;
	 			}else{
		  			upperBound=middle;
	 			}
				
 			}

			//trace("returning time: " + upperBound );
  			return upperBound;// m_keyframes.begin() + upperBound;
  			
  		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalCoreAnimation
	{
		private var m_listCallbacks:Array;	//CallbackRecord
		private var m_duration:Number;
		private var m_listCoreTrack:Array; //CalCoreTrack
		private var m_name:String;
		private var m_filename:String;
		
		public function CalCoreAnimation():void {
			m_listCallbacks = new Array();
			m_listCoreTrack = new Array();
		}

		/*****************************************************************************
		* Adds a core track.
		*
		* This function adds a core track to the core animation instance.
		*
		* @param pCoreTrack A pointer to the core track that should be added.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/
		public function addCoreTrack( coreTrack:CalCoreTrack ):Boolean {
			m_listCoreTrack.push(coreTrack);
			return true;
		}

		/*****************************************************************************
		* Provides access to a core track.
		*
		* This function returns the core track for a given bone ID.
		*
		* @param coreBoneId The core bone ID of the core track that should be
		*                   returned.
		*
		* @return One of the following values:
		*         \li a pointer to the core track
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getCoreTrack( coreBoneId:int ):CalCoreTrack {
			
			// loop through all core track
			for each(var track:CalCoreTrack in m_listCoreTrack) {

				// check if we found the matching core bone
				if(track.getCoreBoneId() == coreBoneId) return track;
			}
		
			// no match found
			return null;
  		}

		/*****************************************************************************
		* Returns the duration.
		*
		* This function returns the duration of the core animation instance.
		*
		* @return The duration in seconds.
		*****************************************************************************/
		public function get duration():Number {
			return m_duration;
		}

		/*****************************************************************************
		* Sets the duration.
		*
		* This function sets the duration of the core animation instance.
		*
		* @param duration The duration in seconds that should be set.
		*****************************************************************************/		
		public function set duration( duration:Number ):void {
			m_duration = duration;
		}
		
		public function scale( factor:Number ):void {
			// loop through all core track
			for each(var track:CalCoreTrack in m_listCoreTrack){
				track.scale(factor);
			}
		}
		
		public function set filename(filename:String):void {
			m_filename = filename;
		}
  
		public function get filename():String {
			return m_filename;
		}
		
		public function set name( name:String ):void {
			m_name = name;
		}
		
		public function get name():String {
			return name;
		}

 // void registerCallback(CalAnimationCallback *callback,float min_interval);
 // void removeCallback(CalAnimationCallback *callback);
 
		/*****************************************************************************
		* Gets the number of core tracks for this core animation.
		*
		* This function returns the number of core tracks used for this core animation.
		*
		* @return The number of core tracks
		*****************************************************************************/
		public function getTrackCount():int {
			return m_listCoreTrack.length;
		}
		
		public function getListCoreTrack():Array {
			return m_listCoreTrack;
		}
		
		public function getTotalNumberOfKeyframes():uint {
			
			var nbKeys:uint = 0;
			for each(var track:CalCoreTrack in m_listCoreTrack) {
				nbKeys += track.getCoreKeyframeCount();
			}
			return nbKeys;
		}

		public function getCallbackList():Array { 
			return m_listCallbacks; 
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class AnimationAction extends CalAnimation
	{
		private var m_delayIn:Number;
		private var m_delayOut:Number;
		private var m_delayTarget:Number;
		private var m_weightTarget:Number;
		private var m_autoLock:Boolean;
		
		public function AnimationAction( coreAnimation:CalCoreAnimation ):void {
			
			super(coreAnimation);
			setType(CalAnimation.TYPE_ACTION);
		}

		/*****************************************************************************
		* Executes the animation action instance.
		*
		* This function executes the animation action instance.
		*
		* @param delayIn The time in seconds until the animation action instance
		*                reaches the full weight from the beginning of its execution.
		* @param delayOut The time in seconds in which the animation action instance
		*                 reaches zero weight at the end of its execution.
		* @param weightTarget No doxygen comment for this. FIXME.
		* @param autoLock     This prevents the Action from being reset and removed
		*                     on the last keyframe if true.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/
 		public function execute( delayIn:Number = 1.0, delayOut:Number = 1.0, 
 								weightTarget:Number = 1.0, autoLock:Boolean = false):Boolean {
 			
			setState(CalAnimation.STATE_IN);
			setWeight(0.0);
			m_delayIn = delayIn;
			m_delayOut = delayOut;
			setTime(0.0);
			m_weightTarget = weightTarget;
			m_autoLock = autoLock;
			
			return true;
 			
 		}
 		
		public function update( deltaTime:Number ):Boolean {
			
			 // update animation action time
			if(getState() != CalAnimation.STATE_STOPPED) {
				setTime( getTime() + deltaTime * getTimeFactor() );
  			}

			// handle IN phase
			if(getState() == CalAnimation.STATE_IN) {
				// check if we are still in the IN phase
				if(getTime() < m_delayIn) {
					setWeight(getTime() / m_delayIn * m_weightTarget);
					//m_weight = m_time / m_delayIn;
    			}else{
					setState(CalAnimation.STATE_STEADY);
					setWeight(m_weightTarget);
 				}
  			}

			// handle STEADY
			if(getState() == CalAnimation.STATE_STEADY) {
				// check if we reached OUT phase
				if(!m_autoLock && getTime() >= getCoreAnimation().duration - m_delayOut) {
      				setState(CalAnimation.STATE_OUT);
    			// if the anim is supposed to stay locked on last keyframe, reset the time here.
    			} else if (m_autoLock && getTime() > getCoreAnimation().duration ) {
      				setState(CalAnimation.STATE_STOPPED);
      				setTime(getCoreAnimation().duration );
    			}      
  			}

			// handle OUT phase
			if(getState() == STATE_OUT) {
				// check if we are still in the OUT phase
				if(getTime() < getCoreAnimation().duration ) {
					setWeight((getCoreAnimation().duration - getTime()) / m_delayOut * m_weightTarget);
	    		}else{
					// we reached the end of the action animation
					setWeight(0.0);
	      			return false;
	    		}
  			}
  			
			return true;
		}
		
		

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalAnimationCycle extends CalAnimation {
		
		private var m_targetDelay:Number;
		private var m_targetWeight:Number;
		
		public function CalAnimationCycle( coreAnimation:CalCoreAnimation ):void {
			super(coreAnimation);
			setType(CalAnimation.TYPE_CYCLE);
			setState(CalAnimation.STATE_SYNC);
			
			// set default weights and delay
  			setWeight(0.0);
  			m_targetDelay = 0.0;
			m_targetWeight = 0.0;
		}

		public function blend( weight:Number, delay:Number):Boolean {
			//trace("CalAnimation::blend -- with weight: " + weight + " delay: " + delay);
			m_targetWeight = weight;
  			m_targetDelay = delay;
  			return true;
		}
		
		public function setAsync( time:Number, duration:Number ):void {
			
			// check if thie animation cycle is already async
			if(getState() != CalAnimation.STATE_ASYNC) {
	    		if(duration == 0.0) {
	      			setTimeFactor(1.0);
	      			setTime(0.0);
	    		}else{
	      			setTimeFactor(getCoreAnimation().duration / duration);
	      			setTime(time * getTimeFactor());
	    		}

    			setState(CalAnimation.STATE_ASYNC);
 			}	
		}
		
		public function update( deltaTime:Number ):Boolean {
			 
			 if(m_targetDelay <= Math.abs(deltaTime)) {
    			// we reached target delay, set to full weight
				setWeight(m_targetWeight);
				m_targetDelay = 0.0;

				// check if we reached the cycles end
    			if(getWeight() == 0.0) return false;
  			
  			}else{
    			// not reached target delay yet, interpolate between current and target weight
    			var factor:Number;
    			factor = deltaTime / m_targetDelay;
   				setWeight((1.0 - factor) * getWeight() + factor * m_targetWeight);
    			m_targetDelay -= deltaTime;
  			}

 			// update animation cycle time if it is in async state
  			if(getState() == CalAnimation.STATE_ASYNC) {
    			setTime(getTime() + deltaTime * getTimeFactor());
    			if(getTime() >= getCoreAnimation().duration ) {
      				setTime( getTime() % getCoreAnimation().duration );
    			}
    			if (getTime() < 0)
      				setTime(getTime() + getCoreAnimation().duration);

  			}

  			return true;

		}
	

		
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalEvent extends Event
	{
		public static const SKELETON_LOADED:String = "skeletonLoaded";
		public static const	ANIMATION_LOADED:String = "animationLoaded";
		public static const	MESH_LOADED:String = "meshLoaded";
		public static const	MATERIAL_LOADED:String = "animationLoaded";

		public var content:Object;
		public var id:int;

		public function CalEvent(type:String, content:Object, id:int = -1, bubbles:Boolean=false, cancelable:Boolean=false):void {
			super(type, bubbles, cancelable);
			this.content = content;
			this.id = id;
		}
		
		
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalConstant
	{
		public static var SKELETON_FILE_EXTENSION:String  = "CSF";
		public static var ANIMATION_FILE_EXTENSION:String = "CAF";
		public static var MESH_FILE_EXTENSION:String      = "CMF";
		public static var MATERIAL_FILE_EXTENSION:String  = "CRF";

		public static var SKELETON_XMLFILE_EXTENSION:String  = "XSF";
		public static var ANIMATION_XMLFILE_EXTENSION:String  = "XAF";
		public static var MESH_XMLFILE_EXTENSION:String = "XMF";
		public static var MATERIAL_XMLFILE_EXTENSION:String  = "XRF";

		// library version       // 0.11.0
		public static var LIBRARY_VERSION:int = 1100;

		// file versions
		public static var CURRENT_FILE_VERSION:int = LIBRARY_VERSION;
		public static var EARLIEST_COMPATIBLE_FILE_VERSION:int = 699;
 
		public function CalConstant() {
			
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */

/*****************************************************************************/
/** 
 * CalAbstractMixer defines the API that CalModel relies on for
 * blending and scheduling animations. A third party mixer must
 * implement this API in order to register itself with the
 * CalModel::setAbstractMixer method. The default mixer (CalMixer) is
 * an example of such implementation.
 *
 * cal3d expects a mixer to handle two tasks : scheduling and
 * blending. Scheduling refers to everything related to time such
 * as when an animation must run or when it must stop. Blending
 * defines how concurrent animations influence each other: for 
 * instance walking and waving.
 *
 * If CalMixer proves to be insufficient for the applications needs,
 * an alternate mixer can be implemented and used without notifying
 * cal3d in any way. It is not mandatory to subclass
 * CalAbstractMixer. However, when chosing this path, one must also
 * avoid using the CalModel::update method because it would use the
 * default mixer instantiated by the CalModel::create method with
 * undesirable side effects. In addition libraries based on cal3d
 * (think NebulaDevice or OpenSceneGraph adapters) are not aware of
 * these constraints and will keep calling the CalModel::update method of
 * CalModel regardless.
 *
 * Subclassing CalAbstractMixer when implementing an alternate mixer
 * therefore provides a better integration with cal3d and libraries
 * that rely on CalModel. However, an additional effort is required in
 * order to achieve compatibility with libraries or applications that
 * rely on the CalMixer API (i.e. that use methods such as blendCycle
 * or executeAction).  The CalMixer API is not meant to be generic and
 * there is no reason to define an abstract class that specifies
 * it. For historical reasons and because CalMixer is the default
 * mixer, some applications and libraries (think Soya or CrystalSpace)
 * depend on it. If they want to switch to a scheduler with extended
 * capabilities it might be painfull for them to learn a completely
 * different API. A scheduler with the ambition to obsolete CalMixer
 * should therefore provide an API compatible with it to ease the
 * migration process.
 *
 * Short summary, if you want to write a new mixer:
 *
 * 1) An external mixer: ignore CalAbstractMixer and implement a mixer
 * of your own. Avoid calling CalModel::update and any library or
 * application that will call it behind your back. Avoid libraries and
 * applications that rely on the default mixer CalMixer, as returned
 * by CalModel::getMixer.
 *
 * 2) A mixer registered in cal3d : subclass CalAbstractMixer,
 * register it with CalModel::setAbstractMixer.  Avoid libraries and
 * applications that rely on the default mixer CalMixer, as returned
 * by CalModel::getMixer. CalModel::getMixer will return a null
 * pointer if CalModel::setAbstractMixer was called to set
 * a mixer that is not an instance of CalMixer.
 *
 * 3) A CalMixer replacement : same as 2) and provide a subclass of
 * your own mixer that implements the CalMixer API so that existing
 * applications can switch to it by calling CalModel::getAbstractMixer
 * instead of CalModel::getMixer. The existing code using the CalMixer
 * methods will keep working and the developper will be able to 
 * switch to a new API when convenient.
 *
 *****************************************************************************/
class CalAbstractMixer
	{
		public function CalAbstractMixer():void {
		
		}
		
		/*****************************************************************************
		*
		* Is the object an instance of the default mixer (i.e. an instance of CalMixer) ?
		*
		* @return \li \b true if an instance of CalMixer
		*         \li \b false if not an instance of CalMixer
		*
		*****************************************************************************/
		public function isDefaultMixer():Boolean { 
			return false; 
		}

 		/*****************************************************************************
 		* 
 		* Notifies the instance that updateAnimation was last called
 		* deltaTime seconds ago. The internal scheduler of the instance
 		* should terminate animations or update the timing information of
 		* active animations accordingly. It should not blend animations
 		* together or otherwise modify the CalModel associated to these
 		* animations.
 		*
 		* The CalModel::update method will call updateSkeleton immediately
 		* after updateAnimation if the instance was allocated by
  		* CalModel::create (in which case it is a CalMixer instance) or if
 		* the instance was set via CalModel::setAbstractMixer.
 		*
 		* @param deltaTime The elapsed time in seconds since the last call.
 		*
 		*****************************************************************************/
		public function updateAnimation( deltaTime:Number ):void {
		
		}

		/*****************************************************************************
		*
		* Updates the skeleton of the corresponding CalModel (as provided to
		* the create method) to match the current animation state (as
		* updated by the last call to updateAnimation).  The tracks of each
		* active animation are blended to compute the position and
		* orientation of each bone of the skeleton. The updateAnimation
		* method should be called just before calling updateSkeleton to
  		* define the set of active animations.
		*
		* The CalModel::update method will call updateSkeleton immediately
		* after updateAnimation if the instance was allocated by
		* CalModel::create (in which case it is a CalMixer instance) or if
		* the instance was set via CalModel::setAbstractMixer.
		*
		*****************************************************************************/
		public function updateSkeleton():void {
			
		}
		

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalSubmesh
	{
		private var m_pCoreSubmesh:CalCoreSubmesh;
		private var m_vectorMorphTargetWeight:Array;
		private var m_vectorVertex:Array;
		private var m_vectorNormal:Array;
		private var m_vectorvectorTangentSpace:Array;
		private var m_vectorFace:Array;
		private var m_vectorPhysicalProperty:Array;
		private var m_vertexCount:int;
		private var m_faceCount:int;
		private var m_coreMaterialId:int;
		private var m_bInternalData:Boolean
		
		public function CalSubmesh( coreSubmesh:CalCoreSubmesh ):void {

			m_pCoreSubmesh = coreSubmesh;
			//m_vectorFace = new Array(m_pCoreSubmesh.getFaceCount());
			
			m_vectorFace = m_pCoreSubmesh.getVectorFace();
			
			// set the initial lod level
			setLodLevel(1.0);

			// set the initial material id
			m_coreMaterialId = -1;
  
			//Setting the morph target weights
			m_vectorMorphTargetWeight = new Array(m_pCoreSubmesh.getCoreSubMorphTargetCount());
			var morphTargetId:int;
			for(morphTargetId = 0; morphTargetId < m_pCoreSubmesh.getCoreSubMorphTargetCount(); ++morphTargetId) {
				m_vectorMorphTargetWeight[morphTargetId] = 0.0;
			}

			// check if the submesh instance must handle the vertex and normal data internally
			if( m_pCoreSubmesh.getSpringCount() > 0 ) {
			
    			// get the vertex vector of the core submesh
    			var vectorVertex:Array = m_pCoreSubmesh.getVectorVertex();
				m_vectorVertex = new Array(vectorVertex.length);
				
				m_vectorPhysicalProperty = new Array( m_pCoreSubmesh.getVertexCount() );
					
				// copy the data from the core submesh as default values
				var vertexId:int;
				for(vertexId = 0; vertexId < m_pCoreSubmesh.getVertexCount(); ++vertexId) {
					
					// copy the vertex data
					m_vectorVertex[vertexId] = vectorVertex[vertexId].position;
					
					var vertex:Vertex = new Vertex();
					vertex.position = vectorVertex[vertexId].position;
					//vertex.positionOld = vectorVertex[vertexId].position;
					 m_vectorPhysicalProperty[vertexId] = vertex;
					//m_vectorPhysicalProperty[vertexId].position = vectorVertex[vertexId].position;
					//m_vectorPhysicalProperty[vertexId].positionOld = vectorVertex[vertexId].position;

					// copy the normal data
					m_vectorNormal[vertexId] = vectorVertex[vertexId].normal;
				}

				m_bInternalData = true;
			
			}else{
				m_bInternalData = false;
			}
		}

		/*****************************************************************************
		* Provides access to the core submesh.
		*
		* This function returns the core submesh on which this submesh instance is
		* based on.
		*
		* @return One of the following values:
		*         \li a pointer to the core submesh
		*         \li \b 0 if an error happend
		*****************************************************************************/	
		public function getCoreSubmesh():CalCoreSubmesh {
			return m_pCoreSubmesh;
		}
		
		/*****************************************************************************
		* Returns the core material ID.
		*
		* This function returns the core material ID of the submesh instance.
		*
		* @return One of the following values:
		*         \li the \b ID of the core material
		*         \li \b -1 if an error happend
		*****************************************************************************/		
		public function getCoreMaterialId():int {
			return m_coreMaterialId;
		}
		
		/*****************************************************************************
		* Returns the number of faces.
		*
		* This function returns the number of faces in the submesh instance.
		*
		* @return The number of faces.
		  *****************************************************************************/
		public function getFaceCount():int {
			return m_faceCount;
		}
	
		/*****************************************************************************
		* Provides access to the face data.
		*
		* This function returns the face data (vertex indices) of the submesh
		* instance. The LOD setting of the submesh instance is taken into account.
		*
		* @param pFaceBuffer A pointer to the user-provided buffer where the face
		*                    data is written to.
		*
		* @return The number of faces written to the buffer.
		*****************************************************************************/		
		public function getFaces():Array {
			//return m_faceCount;
			return m_vectorFace;
		}

		/*****************************************************************************
		* Returns the normal vector.
		*
		* This function returns the vector that contains all normals of the submesh
		* instance.
		*
		* @return A reference to the normal vector.
		*****************************************************************************/		
		public function getVectorNormal():Array {
			return m_vectorNormal;
		}
		
		/*****************************************************************************
		* Returns the tangent space vector-vector.
		*
		* This function returns the vector that contains all tangent space bases of
		* the submesh instance. This vector contains another vector
		* because there can be more than one texture map at each vertex.
		*
		* @return A reference to the tangent space vector-vector.
		*****************************************************************************/		
		public function getVectorVectorTangentSpace():Array {
			return m_vectorvectorTangentSpace;
		}
		
		/*****************************************************************************
		* Returns the physical property vector.
		*
		* This function returns the vector that contains all physical properties of
		* the submesh instance.
		*
		* @return A reference to the physical property vector.
		*****************************************************************************/		
		public function getVectorPhysicalProperty():Array {
			return m_vectorPhysicalProperty;
		}

		/*****************************************************************************
		* Returns the vertex vector.
		*
		* This function returns the vector that contains all vertices of the submesh
		* instance.
		*
		* @return A reference to the vertex vector.		
		*****************************************************************************/		
		public function getVectorVertex():Array {
			print("Getting vector array!");
			return m_vectorVertex;
		}
		
		/*****************************************************************************
		* Returns the number of vertices.
		*
		* This function returns the number of vertices in the submesh instance.
		*
		* @return The number of vertices.
		*****************************************************************************/		
		public function getVertexCount():int {
			return m_vertexCount;
		}

		/*****************************************************************************
		* Returns if the submesh instance handles vertex data internally.
		*
		* This function returns whether the submesh instance handles vertex data
		* internally.
		*
		* @return One of the following values:
		*         \li \b true if vertex data is handled internally
		*         \li \b false if not
		*****************************************************************************/		
		public function hasInternalData():Boolean {
			return m_bInternalData;
		}

		/*****************************************************************************
		* Disable internal data (and thus springs system)
		*
		*****************************************************************************/
		public function disableInternalData():void {
		
			if(m_bInternalData) {
			    m_vectorVertex.clear();
			    m_vectorNormal.clear();
			    m_vectorvectorTangentSpace.clear();
			    m_vectorPhysicalProperty.clear();
			    m_bInternalData=false;
			  }
		}
		
		/*****************************************************************************
		* Sets the core material ID.
		*
		* This function sets the core material ID of the submesh instance.
 		*
		* @param coreMaterialId The core material ID that should be set.
		*****************************************************************************/				
		public function setCoreMaterialId( coreMaterialId:int ):void {
			
			m_coreMaterialId = coreMaterialId;
		}
		
 		public function setLodLevel( lodLevel:Number ):void {
 			
 			// clamp the lod level to [0.0, 1.0]
			if(lodLevel < 0.0) lodLevel = 0.0;
			if(lodLevel > 1.0) lodLevel = 1.0;

			// get the lod count of the core submesh
			var lodCount:int = m_pCoreSubmesh.getLodCount();
 
			// calculate the target lod count
			lodCount = (1.0 - lodLevel) * lodCount;

			//trace("CalSubmesh::setLodLevel -- m_vertexCount " + m_vertexCount );
			//trace(m_pCoreSubmesh);
			// calculate the new number of vertices
			m_vertexCount = m_pCoreSubmesh.getVertexCount() - lodCount;

			// get face vector of the core submesh
			var vectorFace:Array = m_pCoreSubmesh.getVectorFace();
			
			// get face vector of the core submesh
			var vectorVertex:Array = m_pCoreSubmesh.getVectorVertex(); //  std::vector<CalCoreSubmesh::Vertex>& 

			// calculate the new number of faces
			m_faceCount = vectorFace.length;

			var vertexId:int;
			for(vertexId = vectorVertex.length - 1; vertexId >= m_vertexCount; vertexId--) {
				m_faceCount -= vectorVertex[vertexId].faceCollapseCount;
			}

			
			var faceId:int = 0;
			for each(var face:Face in vectorFace){
	
					var faceCoords:Array = new Array(3);
				//trace(f.vertexId[0] + " " + f.vertexId[1] + " " + f.vertexId[2] );
				for(vertexId = 0; vertexId < 3; vertexId++){
					
					var collapsedVertexId:int = face.vertexId[vertexId];
					
					while(collapsedVertexId >= m_vertexCount) collapsedVertexId = vectorVertex[collapsedVertexId].collapseId;
		
					// store the collapse vertex id in the submesh face vector
					//trace("m_vectorFace[" + faceId + "].vertexId[" + vertexId + "] = " + collapsedVertexId);
					//trace(
					//m_vectorFace[faceId].vertexId[vertexId] = collapsedVertexId;
					faceCoords[vertexId] = collapsedVertexId;
				}
				
				var fface:Face = new Face(faceCoords);
				m_vectorFace[faceId] = fface;
				++faceId;
			}

			/*
			// fill the face vector with the collapsed vertex ids
			var faceId:int;
			for(faceId = 0; faceId < m_faceCount; ++faceId) {
				
				var newFaceCoords:Array = new Array(3);
				//var vertexId:int
				for(vertexId = 0; vertexId < 3; ++vertexId) {
					
					// get the vertex id
					var collapsedVertexId:uint;
					collapsedVertexId = vectorFace[faceId].vertexId[vertexId];
					trace("VertexId " + vertexId + " collapsedVertexId " + collapsedVertexId);
					
					// collapse the vertex id until it fits into the current lod level
					while(collapsedVertexId >= m_vertexCount) collapsedVertexId = vectorVertex[collapsedVertexId].collapseId;
		
					// store the collapse vertex id in the submesh face vector
					trace("m_vectorFace[" + faceId + "].vertexId[" + vertexId + "] = " + collapsedVertexId);
					//trace(
					//m_vectorFace[faceId].vertexId[vertexId] = collapsedVertexId;
					newFaceCoords[vertexId] = collapsedVertexId;
				}
				var face:Face = new Face(newFaceCoords);
				m_vectorFace[faceId] = face;
			}
			*/
				
				
 		}
 		
 		/*****************************************************************************
		* Returns true if tangent vectors are enabled.
		*
		* This function returns true if the submesh contains tangent vectors.
		*
		* @return True if tangent vectors are enabled.
		*****************************************************************************/		
		public function isTangentsEnabled( mapId:int ):Boolean {
			return m_pCoreSubmesh.isTangentsEnabled(mapId);
		}
		
		/*****************************************************************************
		* Enables (and calculates) or disables the storage of tangent spaces.
		*
		* This function enables or disables the storage of tangent space bases.
		*****************************************************************************/		
		public function enableTangents( mapId:int, enabled:Boolean ): Boolean {
			
			if(!m_pCoreSubmesh.enableTangents(mapId,enabled))
				return false;

			if(!m_bInternalData)
				return true;

			if(!enabled) {
				m_vectorvectorTangentSpace[mapId].clear();
				return true;
			}

			//m_vectorvectorTangentSpace[mapId].reserve(m_pCoreSubmesh.getVertexCount());
			//m_vectorvectorTangentSpace[mapId].resize(m_pCoreSubmesh.getVertexCount());
	
			// get the tangent space vector of the core submesh
			var vectorTangentSpace:Array = m_pCoreSubmesh.getVectorVectorTangentSpace()[mapId];

			// copy the data from the core submesh as default values
			var vertexId:int;
			for(vertexId = 0; vertexId < m_pCoreSubmesh.getVertexCount(); vertexId++) {      
				// copy the tangent space data
				m_vectorvectorTangentSpace[mapId][vertexId].tangent = vectorTangentSpace[vertexId].tangent;
				m_vectorvectorTangentSpace[mapId][vertexId].crossFactor = vectorTangentSpace[vertexId].crossFactor;
 			}

			return true;    

		}
		
		public function getVectorWeight():Array {
			return null;
		}

 		/*****************************************************************************
		* Sets weight of a morph target with the given id.
		*
		* @param blendId The morph target id.
		* @param weight The weight to be set.
		*****************************************************************************/		
		public function setMorphTargetWeight( blendId:int, weight:Number ):void {
			m_vectorMorphTargetWeight[blendId] = weight;
		}

		/*****************************************************************************
		* Gets weight of a morph target with the given id.
		*
		 * @param blendId The morph target id.
		* @return The weight of the morph target.
		*****************************************************************************/		
		public function getMorphTargetWeight( blendId:int ):Number {
			return m_vectorMorphTargetWeight[blendId];
		}

		/*****************************************************************************
		 Gets weight of the base vertices.
		*
		* @return The weight of the base vertices.
		*****************************************************************************/		
		public function getBaseWeight():Number {
			
			var baseWeight:Number = 1.0;
			var morphTargetCount:int = getMorphTargetWeightCount();
			var morphTargetId:int;
			
			for(morphTargetId=0; morphTargetId < morphTargetCount; ++morphTargetId) {
    			baseWeight -= m_vectorMorphTargetWeight[morphTargetId];
			}
			
			return baseWeight;
		}

		/*****************************************************************************
		* Returns the number of weights.
 		*
		* This function returns the number of weights.
		*
		* @return The number of weights.
		*****************************************************************************/		
		public function getMorphTargetWeightCount():int {
			return m_vectorMorphTargetWeight.length;
		}

		/*****************************************************************************
		* Returns the morph target weight vector.
		*
		* This function returns the vector that contains all weights for
		* each morph target instance.
		*
		* @return A reference to the weight vector.
		*****************************************************************************/		
		public function getVectorMorphTargetWeight():Array {
			return m_vectorMorphTargetWeight;
		}
		
		

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalMesh
	{
		private var m_pModel:CalModel;
		private var m_pCoreMesh:CalCoreMesh;
		private var m_vectorSubmesh:Array; //CalSubmesh
		
		public function CalMesh( pCoreMesh:CalCoreMesh ):void{
			
			if(pCoreMesh == null) return;
			
			m_pCoreMesh = pCoreMesh;

			// clone the mesh structure of the core mesh
			var vectorCoreSubmesh:Array = pCoreMesh.getVectorCoreSubmesh();
			//trace("CalMesh::CalMesh -- vectorCoreSubmesh.length: " + vectorCoreSubmesh.length);
			
			// get the number of submeshes
			var submeshCount:int = vectorCoreSubmesh.length;

			// reserve space in the bone vector
			m_vectorSubmesh = new Array(submeshCount);

			// clone every core submesh
			for(var submeshId:int = 0; submeshId < submeshCount; ++submeshId) {
				m_vectorSubmesh[submeshId] = new CalSubmesh(vectorCoreSubmesh[submeshId]);
			}

		}

		/*****************************************************************************
		* Provides access to the core mesh.
		*
		* This function returns the core mesh on which this mesh instance is based on.
		*
		* @return One of the following values:
		*         \li a pointer to the core mesh
		*         \li \b 0 if an error happend
		*****************************************************************************/				
		public function getCoreMesh():CalCoreMesh {
			return m_pCoreMesh;
		}

 		/*****************************************************************************
		* Provides access to a submesh.
		*
		* This function returns the submesh with the given ID.
		*
		* @param id The ID of the submesh that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the submesh
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getSubmesh( id:int ):CalSubmesh {
			
			if((id < 0) || (id >= m_vectorSubmesh.length) ) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return null;
			}

			return m_vectorSubmesh[id];
		}

 		/*****************************************************************************
		* Returns the number of submeshes.
		*
		* This function returns the number of submeshes in the mesh instance.
		*
		* @return The number of submeshes.
		*****************************************************************************/		
		public function getSubmeshCount():int {
			return m_vectorSubmesh.length;
		}
		
		
		/*****************************************************************************
		* Returns the submesh vector.
		*
		* This function returns the vector that contains all submeshes of the mesh
		* instance.
		*
		* @return A reference to the submesh vector.
		*****************************************************************************/
		public function getVectorSubmesh():Array {
			return m_vectorSubmesh;
		}

 		/*****************************************************************************
		* Sets the LOD level.
		*
		* This function sets the LOD level of the mesh instance.
		*
		* @param lodLevel The LOD level in the range [0.0, 1.0].
		*****************************************************************************/		
		public function setLodLevel( lodLevel:Number ):void {
	
			// change lod level of every submesh
 			var submeshId:int;
			for(submeshId = 0; submeshId < m_vectorSubmesh.length; ++submeshId) {
				// set the lod level in the submesh
				m_vectorSubmesh[submeshId].setLodLevel(lodLevel);
			}
			
		}

 		/*****************************************************************************
		* Sets the material set.
		*
		* This function sets the material set of the mesh instance.
		*
		* @param setId The ID of the material set.
		*****************************************************************************/		
		public function setMaterialSet( setId:int ):void {
			// change material of every submesh
			var submeshId:int;
			for(submeshId = 0; submeshId < m_vectorSubmesh.length; ++submeshId) {
				// get the core material thread id of the submesh
				var coreMaterialThreadId:int;
				coreMaterialThreadId = m_vectorSubmesh[submeshId].getCoreSubmesh().getCoreMaterialThreadId();

				// get the core material id for the given set id in the material thread
				var coreMaterialId:int;
				coreMaterialId = m_pModel.getCoreModel().getCoreMaterialId(coreMaterialThreadId, setId);

				// set the new core material id in the submesh
				m_vectorSubmesh[submeshId].setCoreMaterialId(coreMaterialId);
			}
		}

 		/*****************************************************************************
		* Sets the model.
		*
		* This function sets the model to which the mesh instance is attached to.
		*
		* @param pModel The model to which the mesh instance should be attached to.
		*****************************************************************************/		
		public function setModel( pModel:CalModel ):void {
			m_pModel = pModel;
		}

		/*****************************************************************************
		* Disable internal data (and thus springs system)
		*
		*****************************************************************************/		
		public function disableInternalData():void {
			 // disable internal data of every submesh
			var submeshId:int;
			for(submeshId = 0; submeshId < m_vectorSubmesh.length; ++submeshId) {
				// disable internal data of the submesh
				m_vectorSubmesh[submeshId].disableInternalData();
			}
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalBone
	{

		private var m_pCoreBone:CalCoreBone;
		private var m_pSkeleton:CalSkeleton;
		private var m_accumulatedWeight:Number;
		private var m_accumulatedWeightAbsolute:Number;
		private var m_translation:CalVector;
		private var m_rotation:CalQuaternion;
		private var m_translationAbsolute:CalVector;
		private var m_rotationAbsolute:CalQuaternion;
		private var m_translationBoneSpace:CalVector;
		private var m_rotationBoneSpace:CalQuaternion;
		private var m_transformMatrix:CalMatrix;  
		private var m_boundingBox:CalBoundingBox;
 
 		/*****************************************************************************
		* CONSTRUCTOR
		*
		* This function is the default constructor of the skeleton instance.
		*
		* @param coreSkeleton	
		*****************************************************************************/ 
		public function CalBone( coreBone:CalCoreBone ):void {
			
			if(coreBone == null){ 
				trace("CalBone::CalBone -- coreBone is null");
			}
			m_pCoreBone = coreBone;
			
			//init
			m_rotation = new CalQuaternion();
			m_translation = new CalVector();
			m_translationAbsolute = new CalVector();
			m_translationBoneSpace = new CalVector();
			m_rotationAbsolute = new CalQuaternion();
			m_rotationBoneSpace = new CalQuaternion();
			
			//craete empty transform matrix
			m_transformMatrix = new CalMatrix();
			clearState();
		}

		/*****************************************************************************
		* Interpolates the current state to another state.
		*
		* This function interpolates the current state (relative translation and
		* rotation) of the bone instance to another state of a given weight.
		*
		* @param weight The blending weight.
		* @param translation The relative translation to be interpolated to.
		* @param rotation The relative rotation to be interpolated to.
		*****************************************************************************/
		public function blendState( weight:Number, translation:CalVector, rotation:CalQuaternion ):void {
			
			if(m_accumulatedWeightAbsolute == 0.0) {
				// it is the first state, so we can just copy it into the bone state
				m_translationAbsolute = translation;
				m_rotationAbsolute = rotation;
				//m_translationAbsolute.setToVector(translation);
				//m_rotationAbsolute.setToQuaternion(rotation);

				m_accumulatedWeightAbsolute = weight;
			}else {
				// it is not the first state, so blend all attributes
				var factor:Number;
				factor = weight / (m_accumulatedWeightAbsolute + weight);
	
				m_translationAbsolute.blend(factor, translation);
				m_rotationAbsolute.blend(factor, rotation);

				m_accumulatedWeightAbsolute += weight;
			}	
		}

		/*****************************************************************************
		* Calculates the current state.
		*
		* This function calculates the current state (absolute translation and
		* rotation, as well as the bone space transformation) of the bone instance
		* and all its children.
		*****************************************************************************/
		public function calculateState():void {
		
			// check if the bone was not touched by any active animation
			if(m_accumulatedWeight == 0.0) {
				// set the bone to the initial skeleton state
				m_translation = m_pCoreBone.translation.clone();
				m_rotation = m_pCoreBone.rotation.clone();
				
				//m_translation.setToVector(m_pCoreBone.translation);
				//m_rotation.setToQuaternion(m_pCoreBone.rotation);
				
			}

			// get parent bone id
			var parentId:int;
			parentId = m_pCoreBone.parentId;

			if(parentId == -1) {
				// no parent, this means absolute state == relative state
				m_translationAbsolute = m_translation.clone();
 				m_rotationAbsolute = m_rotation.clone();
 				
				//m_translationAbsolute.setToVector(m_translation);
 				//m_rotationAbsolute.setToQuaternion(m_rotation);
			
			}else{
				// get the parent bone
				var pParent:CalBone;
				pParent = m_pSkeleton.getBone(parentId);
				
				/*
				// transform relative state with the absolute state of the parent
				m_translationAbsolute.setToVector(m_translation);
				m_translationAbsolute.multiplyByQuaternion( pParent.getRotationAbsolute() );
				m_translationAbsolute.add( pParent.getTranslationAbsolute() );

				m_rotationAbsolute.setToQuaternion(m_rotation);
				m_rotationAbsolute.multiplyByQuaternion( pParent.getRotationAbsolute() );
				*/
				
			
				// transform relative state with the absolute state of the parent
				//m_translationAbsolute = m_translation.clone();
				//m_translationAbsolute.multiplyByQuaternion( pParent.getRotationAbsolute() );
				
				m_translationAbsolute = 
					CalVector.multiplyVectorByQuaternion(m_translation, pParent.getRotationAbsolute());
		
				m_translationAbsolute.add( pParent.getTranslationAbsolute() );

				

				//m_rotationAbsolute = m_rotation.clone();
			//	m_rotationAbsolute.multiplyByQuaternion( pParent.getRotationAbsolute() );
				
				
				m_rotationAbsolute = 
					CalQuaternion.multiplyQuaternions(m_rotation,pParent.getRotationAbsolute());
			}

			/*
			// calculate the bone space transformation
			m_translationBoneSpace.setToVector(m_pCoreBone.translationBoneSpace);
			m_translationBoneSpace.multiplyByQuaternion( m_rotationAbsolute );
			m_translationBoneSpace.add( m_translationAbsolute );
			
			m_rotationBoneSpace.setToQuaternion(m_pCoreBone.rotationBoneSpace);
			m_rotationBoneSpace.multiplyByQuaternion( m_rotationAbsolute );
			
			// Generate the vertex transform.  If I ever add support for bone-scaling
			// to Cal3D, this step will become significantly more complex.
			m_transformMatrix.setFromQuaternion( m_rotationBoneSpace );
			*/
			
			// calculate the bone space transformation
			//m_translationBoneSpace = m_pCoreBone.translationBoneSpace.clone();
			//m_translationBoneSpace.multiplyByQuaternion( m_rotationAbsolute );
			m_translationBoneSpace =
				CalVector.multiplyVectorByQuaternion(m_pCoreBone.translationBoneSpace, m_rotationAbsolute);
			m_translationBoneSpace.add( m_translationAbsolute );
			
			//m_rotationBoneSpace = m_pCoreBone.rotationBoneSpace.clone();
			//m_rotationBoneSpace.multiplyByQuaternion( m_rotationAbsolute );
			m_rotationBoneSpace =
				CalQuaternion.multiplyQuaternions(m_pCoreBone.rotationBoneSpace,  m_rotationAbsolute);
			
			// Generate the vertex transform.  If I ever add support for bone-scaling
			// to Cal3D, this step will become significantly more complex.
			m_transformMatrix.setFromQuaternion( m_rotationBoneSpace);
			
			
			// calculate all child bones
			var childList:Array = m_pCoreBone.getListChildId();
			for each(var i:int in childList) {
				m_pSkeleton.getBone(i).calculateState();
			}
			
		}

		/*****************************************************************************
		* Clears the current state.
		*
		* This function clears the current state (absolute translation and rotation)
		* of the bone instance and all its children.
		*****************************************************************************/
		public function clearState():void {
			
  			m_accumulatedWeight = 0.0;
  			m_accumulatedWeightAbsolute = 0.0;
  		}

		/*****************************************************************************
		* Provides access to the core bone.
		*
		* This function returns the core bone on which this bone instance is based on.
		*
		* @return One of the following values:
		*         \li a pointer to the core bone
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getCoreBone():CalCoreBone{
			return m_pCoreBone;
		}
 
		/*****************************************************************************
		* Resets the bone to its core state
		*
		* This function changes the state of the bone to its default non-animated
		* position and orientation. Child bones are unaffected and may be animated
		* independently. 
		*****************************************************************************/
 		public function setCoreState():void {
 			
			// set the bone to the initial skeleton state
			m_translation = m_pCoreBone.translation;
			m_rotation = m_pCoreBone.rotation;

			//m_translation.setToVector(m_pCoreBone.translation);
			//m_rotation.setToQuaternion(m_pCoreBone.rotation);
			

			// set the appropriate weights
			m_accumulatedWeightAbsolute = 1.0;
			m_accumulatedWeight = 1.0;

   			calculateState() ;	
 		}

		/*****************************************************************************
		* Resets the bone and children to core states
		*
		* This function changes the state of the bone to its default non-animated
		* position and orientation. All child bones are also set in this manner.
		*****************************************************************************/ 		
		public function setCoreStateRecursive():void {
		
			// set the bone to the initial skeleton state
			m_translation = m_pCoreBone.translation;
			m_rotation = m_pCoreBone.rotation;

			// set the appropriate weights
			m_accumulatedWeightAbsolute = 1.0;
			m_accumulatedWeight = 1.0;

			// set core state for all child bones
			var childListId:Array = m_pCoreBone.getListChildId();
			for each(var i:int in childListId) {
    			m_pSkeleton.getBone(i).setCoreStateRecursive();
			}

			calculateState() ;
			
		}

		/*****************************************************************************
		* Sets the current rotation.
		*
		* This function sets the current relative rotation of the bone instance.
		* Caveat: For this change to appear, calculateState() must be called 
		* afterwards.
		*****************************************************************************/		
		public function setRotation( rotation:CalQuaternion ):void {
			m_rotation = rotation;
			
			//m_rotation.setToQuaternion(rotation);
			
			m_accumulatedWeightAbsolute = 1.0;
			m_accumulatedWeight = 1.0;
		}

		/*****************************************************************************
		* Returns the current rotation.
		*
		* This function returns the current relative rotation of the bone instance.
		*
		* @return The relative rotation to the parent as quaternion.
		*****************************************************************************/		
		public function getRotation():CalQuaternion{
  			return m_rotation;
		}

		/*****************************************************************************
		* Returns the current absolute rotation.
		*
		* This function returns the current absolute rotation of the bone instance.
		*
		* @return The absolute rotation to the parent as quaternion.
		*****************************************************************************/		
		public function getRotationAbsolute():CalQuaternion {
			return m_rotationAbsolute;
		}

		/*****************************************************************************
		* Returns the current bone space rotation.
		*
		* This function returns the current rotation to bring a point into the bone
		* instance space.
		*
		* @return The rotation to bring a point into bone space.
		*****************************************************************************/		
		public function getRotationBoneSpace():CalQuaternion {
			return m_rotationBoneSpace;
		}

		/*****************************************************************************
		* Sets the current translation.
		*
		* This function sets the current relative translation of the bone instance.
		* Caveat: For this change to appear, calculateState() must be called 
		* afterwards.
		*****************************************************************************/		
		public function setTranslation( translation:CalVector ):void {
			
			m_translation = translation;
			//m_translation.setToVector(translation);
			
			m_accumulatedWeightAbsolute = 1.0;
			m_accumulatedWeight = 1.0;
		}

		/*****************************************************************************
		* Returns the current translation.
		*
		* This function returns the current relative translation of the bone instance.
		*
		* @return The relative translation to the parent as quaternion.	
		*****************************************************************************/		
		public function getTranslation():CalVector {
			return m_translation;
		}

		/*****************************************************************************
		* Returns the current absolute translation.
		*
		* This function returns the current absolute translation of the bone instance.
		*
		* @return The absolute translation to the parent as quaternion.
		*****************************************************************************/		
		public function getTranslationAbsolute():CalVector {
			return m_translationAbsolute;
		}

		/*****************************************************************************
		* Returns the current bone space translation.
		*
		* This function returns the current translation to bring a point into the
		*bone instance space.
		*
		* @return The translation to bring a point into bone space.
		*****************************************************************************/		
		public function getTranslationBoneSpace():CalVector {
			return m_translationBoneSpace;
		}

		/*****************************************************************************
		* Returns the current bone space translation.
		*
		* This function returns the current translation to bring a point into the
		*bone instance space.
		*
		* @return The translation to bring a point into bone space.
		*****************************************************************************/
		public function getTransformMatrix():CalMatrix {
			return m_transformMatrix;
		}

		/*****************************************************************************
		* Locks the current state.
		*
		* This function locks the current state (absolute translation and rotation)
		* of the bone instance and all its children.
		*****************************************************************************/		
		public function lockState():void {
			
			// clamp accumulated weight
			if(m_accumulatedWeightAbsolute > 1.0 - m_accumulatedWeight) {
				m_accumulatedWeightAbsolute = 1.0 - m_accumulatedWeight;
			}

			if(m_accumulatedWeightAbsolute > 0.0) {
				if(m_accumulatedWeight == 0.0) {
					// it is the first state, so we can just copy it into the bone state
					m_translation = m_translationAbsolute;
					m_rotation = m_rotationAbsolute;
					
					//m_translation.setToVector( m_translationAbsolute );
					//m_rotation.setToQuaternion(m_rotationAbsolute);
	
					m_accumulatedWeight = m_accumulatedWeightAbsolute;
				}else{
					// it is not the first state, so blend all attributes
					var factor:Number;
					factor = m_accumulatedWeightAbsolute / (m_accumulatedWeight + m_accumulatedWeightAbsolute);
	
					m_translation.blend(factor, m_translationAbsolute);
					m_rotation.blend(factor, m_rotationAbsolute);
	
					m_accumulatedWeight += m_accumulatedWeightAbsolute;
				}

				m_accumulatedWeightAbsolute = 0.0;
			}
		}

		/*****************************************************************************
		* Sets the skeleton.
		*
		* This function sets the skeleton to which the bone instance is attached to.
		*
 		* @param pSkeleton The skeleton to which the bone instance should be
		*                  attached to.
		*****************************************************************************/		
		public function setSkeleton( pSkeleton:CalSkeleton ):void {
			 m_pSkeleton = pSkeleton;
		}

		/*****************************************************************************
		* Calculates the bounding box.
		*
		* This function Calculates the bounding box of the bone instance.
		*
		*****************************************************************************/
		public function calculateBoundingBox():void {
		
			if(!getCoreBone().isBoundingBoxPrecomputed()) return;

			var dir:CalVector = new CalVector(1.0, 0.0, 0.0);
			dir.multiplyByMatrix( getTransformMatrix() );
			m_boundingBox.plane[0].setNormal(dir);

			dir = new CalVector(-1.0, 0.0, 0.0);
			dir.multiplyByMatrix(getTransformMatrix());
			m_boundingBox.plane[1].setNormal(dir);

			dir = new CalVector(0.0, 1.0, 0.0);
			dir.multiplyByMatrix(getTransformMatrix());
			m_boundingBox.plane[2].setNormal(dir);

			dir = new CalVector(0.0, -1.0, 0.0);
			dir.multiplyByMatrix(getTransformMatrix());
			m_boundingBox.plane[3].setNormal(dir);

			dir = new CalVector(0.0, 0.0, 1.0);
			dir.multiplyByMatrix(getTransformMatrix());
			m_boundingBox.plane[4].setNormal(dir);

			dir = new CalVector(0.0, 0.0, -1.0);
			dir.multiplyByMatrix(getTransformMatrix());
			m_boundingBox.plane[5].setNormal(dir);
   
			var i:int;
			for(i=0;i< 6; i++) {
				var position:CalVector;
				getCoreBone().getBoundingData(i,position);
      
				position.multiplyByMatrix( getTransformMatrix() );
				position.add( getTranslationBoneSpace() );

			var planeId:int;
			for(planeId = 0; planeId < 6; ++planeId) {
				if( m_boundingBox.plane[planeId].eval(position) < 0.0 ) {
					m_boundingBox.plane[planeId].setPosition(position);
				}
			}   
		}

		
			
		}

		/*****************************************************************************
		* Returns the current bounding box.
		*
		* This function returns the current bounding box of the bone instance.
		*
		* @return bounding box.
		*****************************************************************************/
		public function getBoundingBox():CalBoundingBox {
			return m_boundingBox;
		}



	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalSkeleton
	{
		private var m_pCoreSkeleton:CalCoreSkeleton;
		private var m_vectorBone:Array; //Array of CalBone
		private var m_isBoundingBoxesComputed:Boolean;

		/*****************************************************************************
		* CONSTRUCTOR
		*
		* This function is the default constructor of the skeleton instance.
		*
		* @param coreSkeleton	
		*****************************************************************************/			
		public function CalSkeleton( pCoreSkeleton:CalCoreSkeleton ):void {
			
			if(pCoreSkeleton == null) return;
			m_pCoreSkeleton = pCoreSkeleton;
			m_vectorBone = new Array();
			 
			// clone the skeleton structure of the core skeleton
			var vectorCoreBone:Array = pCoreSkeleton.vectorCoreBone;

			// get the number of bones
			var boneCount:int = vectorCoreBone.length;

			// clone every core bone
			for(var boneId:int = 0; boneId < boneCount; ++boneId) {
				var bone:CalBone = new CalBone(vectorCoreBone[boneId]);
				
				//trace("CalSkeleton::CalSkeleton -- cloning CoreBone == " + bone);
				//var cv:CalVector = bone.getTranslationAbsolute();
				//trace("CalSkeleton::CalSkeleton -- translation: " + cv.x + " " + cv.y + " " + cv.z);
				// set skeleton in the bone instance
 				bone.setSkeleton(this);

				// insert bone into bone vector
				m_vectorBone.push(bone);
  			}
  		
		}

 		/*****************************************************************************
		* Calculates the state of the skeleton instance.
		*
		* This function calculates the state of the skeleton instance by recursively
		* calculating the states of its bones.
		*****************************************************************************/		
		public function calculateState():void {
			
			// calculate all bone states of the skeleton
			for each(var bone:CalBone in this.m_vectorBone) {
				bone.calculateState();
			}
			
			m_isBoundingBoxesComputed = false;
		}

		/*****************************************************************************
		* Clears the state of the skeleton instance.
		*
		* This function clears the state of the skeleton instance by recursively
		* clearing the states of its bones.
		*****************************************************************************/		
		public function clearState():void {
			
			// clear all bone states of the skeleton
		  	for each(var bone:CalBone in this.m_vectorBone){
				bone.clearState();
			}
  			m_isBoundingBoxesComputed = false;
		}
		
		public function create( pCoreSkeleton:CalCoreSkeleton ):Boolean{
			return true;
		}

		/*****************************************************************************
		* Provides access to a bone.
		*
		* This function returns the bone with the given ID.
		*
		* @param boneId The ID of the bone that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the bone
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getBone( boneId:int ):CalBone {
			return m_vectorBone[boneId];
		}

		/*****************************************************************************
		* Provides access to the core skeleton.
		*
		* This function returns the core skeleton on which this skeleton instance is
		* based on.
		*
		* @return One of the following values:
		*         \li a pointer to the core skeleton
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getCoreSkeleton():CalCoreSkeleton {
			return m_pCoreSkeleton;
		}

		/*****************************************************************************
		* Returns the bone vector.
		*
		* This function returns the vector that contains all bones of the skeleton
		* instance.
		*
		* @return A reference to the bone vector.
		*****************************************************************************/		
		public function getVectorBone():Array {
			return m_vectorBone;
		}

		/*****************************************************************************
		* Locks the state of the skeleton instance.
		*
		* This function locks the state of the skeleton instance by recursively
		* locking the states of its bones.
		*****************************************************************************/		
		public function lockState():void {
			
			for each(var bone:CalBone in this.m_vectorBone){
			  bone.lockState();
  			}	
		}
		
		/*****************************************************************************
		* Calculates axis aligned bounding box of skeleton bones
		*
		* @param min The vector where the min values of bb are stored.
		* @param man The vector where the max values of bb are stored.
		*****************************************************************************/
		public function getBoneBoundingBox( min:CalVector, max:CalVector ):void {
			
			if(!m_isBoundingBoxesComputed) {
				calculateBoundingBoxes();
			}

			var bone:CalBone; // iterator bone
			var translation:CalVector; //iterator translation vector
			for each(bone in this.m_vectorBone) {
				
				translation = bone.getTranslationAbsolute();

			    min.x = max.x = translation.x;
			    min.y = max.y = translation.y;
			    min.z = max.z = translation.z;
  			}

			for each(bone in this.m_vectorBone) {
								
				translation = bone.getTranslationAbsolute();

				if (translation.x > max.x)
					max.x = translation.x;
				else if (translation.x < min.x)
					min.x = translation.x;

				if (translation.y > max.y)
					max.y = translation.y;
				else if (translation.y < min.y)
					min.y = translation.y;

				if (translation.z > max.z)
					max.z = translation.z;
				else if (translation.z < min.z)
					min.z = translation.z;
			}

		}

		/*****************************************************************************
		* Calculates bounding boxes.
		*
		* This function Calculates the bounding box of every bone in the Skeleton.
		*
		*****************************************************************************/	
		public function calculateBoundingBoxes():void {

			if(m_isBoundingBoxesComputed) return;

			for each(var bone:CalBone in this.m_vectorBone){
				bone.calculateBoundingBox();
			}
			m_isBoundingBoxesComputed=true;

		}


		// DEBUG-CODE
		public function getBonePoints():Array {
			
			var bonePoints:Array = new Array();
			
  			for each(var bone:CalBone in m_vectorBone) {
  				bone.calculateState();
				var translation:CalVector = bone.getTranslationAbsolute();
				//var translation:CalVector = bone.getTranslation();
				//trace("CalSkeleton::getBonePoints -- adding bone " + translation );
  				var joint:Object = {name:bone.getCoreBone().name, joint:translation };
  				
  				bonePoints.push(joint);
  			}

  			return bonePoints;

		}
		
		public function getBonePointsStatic( pPoints:Number ):int{
			return -1;
		}
		
		public function getBoneLines():Array{
			var bone:CalBone
			var lines:Array = new Array();
			for each(bone in m_vectorBone) {
				bone.calculateState();
			}
			
  			for each(bone in m_vectorBone) {
			

				var parentId:int = bone.getCoreBone().parentId;

				if(parentId != -1) {
	
					var pParent:CalBone = m_vectorBone[parentId];
	
	      			var translation:CalVector = bone.getTranslationAbsolute();
					var translationParent:CalVector = pParent.getTranslationAbsolute();
					//var translation:CalVector = bone.getTranslation()
					//var translationParent:CalVector = pParent.getTranslation();
					
					//trace("Line created " + translation + " " + translationParent );
					var line:Object = {name:bone.getCoreBone().name, start:translation, end:translationParent};
					//trace("Object: " + line.start + " " + line.end );
					lines.push(line);
				}
  			}
			
			return lines;
			
		}
		
		public function getBoneLinesStatic( pLines:Number ):int{
			return -1;
		}
	
	
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalModel
	{
		private var m_pCoreModel:CalCoreModel;
		private var m_pSkeleton:CalSkeleton;
		private var m_pMixer:CalAbstractMixer;
 		private var m_pMorphTargetMixer:CalMorphTargetMixer;
		private var m_pPhysique:CalPhysique;
		private var m_pSpringSystem:CalSpringSystem;
		private var m_pRenderer:CalRenderer;
		private var m_userData:Object;
		private var m_vectorMesh:Array; //array of CalMesh
		private var m_boundingBox:CalBoundingBox;
		
		/*****************************************************************************
		* Constructs the model instance.
		*
		* This function is the default constructor of the model instance.
		*****************************************************************************/
		public function CalModel( pCoreModel:CalCoreModel ):void {

			if(pCoreModel == null) return;

			m_pCoreModel = pCoreModel;
			m_vectorMesh = new Array();
			m_pSkeleton = new CalSkeleton( pCoreModel.getCoreSkeleton() );
			m_pMixer = new CalMixer(this);
			m_pMorphTargetMixer = new CalMorphTargetMixer(this);
			m_pPhysique = new CalPhysique(this);
			m_pSpringSystem = new CalSpringSystem(this);
 			m_pRenderer = new CalRenderer(this);
		}

		/*****************************************************************************
		* Attachs a mesh.
		*
		* This function attachs a mesh to the model instance.
		*
		* @param coreMeshId The ID of the mesh that should be attached.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/
		public function attachMesh( coreMeshId:int ):Boolean {
			
			// check if the id is valid
			if((coreMeshId < 0) ||(coreMeshId >= m_pCoreModel.getCoreMeshCount())) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}

			// get the core mesh
			var pCoreMesh:CalCoreMesh;
			pCoreMesh = m_pCoreModel.getCoreMesh(coreMeshId);
			//trace("CalModel::attachMesh -- " + pCoreMesh);

			// check if the mesh is already attached
			var meshId:int;
			for(meshId = 0; meshId < m_vectorMesh.length; ++meshId) {
				// check if we found the matching mesh
				if(m_vectorMesh[meshId].getCoreMesh() == pCoreMesh) {
					// mesh is already active -> do nothing
					trace("Mesh already attached");
					return true;
				}
  			}

			// allocate a new mesh instance
			var pMesh:CalMesh = new CalMesh(pCoreMesh);
			if(pMesh == null) {
				//CalError::setLastError(CalError::MEMORY_ALLOCATION_FAILED, __FILE__, __LINE__);
 				return false;
			}

			// set model in the mesh instance
			pMesh.setModel(this);
			//trace("CalModel::attachMesh -- attaching mesh ID " + coreMeshId);
			// insert the new mesh into the active list
			m_vectorMesh.push(pMesh);

			return true;

		}

		/*****************************************************************************
		* Detaches a mesh.
		*
		* This function detaches a mesh from the model instance.
		*
		* @param coreMeshId The ID of the mesh that should be detached.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function detachMesh( coreMeshId:int ):Boolean {
			 /*   
			// check if the id is valid
			if((coreMeshId < 0) ||(coreMeshId >= m_pCoreModel.getCoreMeshCount())) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}

			// get the core mesh
			var pCoreMesh:CalCoreMesh;
			pCoreMesh = m_pCoreModel.getCoreMesh(coreMeshId);

			// find the mesh for the given id
			std::vector<CalMesh *>::iterator iteratorMesh;
			for(iteratorMesh = m_vectorMesh.begin(); iteratorMesh != m_vectorMesh.end(); ++iteratorMesh) {
				// get the mesh
				CalMesh *pMesh;
				pMesh = *iteratorMesh;
		
				// check if we found the matching mesh
				if(pMesh->getCoreMesh() == pCoreMesh) {
					// destroy the mesh
					delete pMesh;
		
					// erase the mesh out of the active mesh list
					m_vectorMesh.erase(iteratorMesh);
		
					return true;
				}
			}
			*/
			return false;
		}

		/*****************************************************************************
		* Provides access to the core model.
		*
		* This function returns the core model on which this model instance is based
		* on.
		*
		* @return One of the following values:
		*         \li a pointer to the core model
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getCoreModel():CalCoreModel {
			return m_pCoreModel;
		}

		/*****************************************************************************
		* Provides access to an attached mesh.
		*
		* This function returns the attached mesh with the given core mesh ID.
		*
		* @param coreMeshId The core mesh ID of the mesh that should be returned.
		*
		* @return One of the following values:
		*         \li a pointer to the mesh
		*         \li \b 0 if an error happend
		*****************************************************************************/		
		public function getMesh( coreMeshId:int ):CalMesh {

 			// check if the id is valid
			if((coreMeshId < 0) ||(coreMeshId >= m_pCoreModel.getCoreMeshCount())) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return null;
			}

			// get the core mesh
			var pCoreMesh:CalCoreMesh = m_pCoreModel.getCoreMesh(coreMeshId);

			// search the mesh
			for(var meshId:int = 0; meshId < m_vectorMesh.length; ++meshId) {
				// check if we found the matching mesh
				if(m_vectorMesh[meshId].getCoreMesh() == pCoreMesh) {
					return m_vectorMesh[meshId];
				}
			}

			return null;		
		}

		/*****************************************************************************
		* Returns the mixer.
		*
		* If a mixer that is not an instance of CalMixer was set with the
		* CalModel::setAbstractMixer method, an INVALID_MIXER_TYPE error (see
 		* CalError) is set and 0 is returned.
		*
		* @return \li a pointer to the mixer
		*         \li \b 0 if an error happend
		*****************************************************************************/ 
 		public function getMixer():CalAbstractMixer { //CalMixer {
 			  
			if(m_pMixer == null) return null;

			if(m_pMixer.isDefaultMixer() == false) {
				//CalError::setLastError(CalError::INVALID_MIXER_TYPE, __FILE__, __LINE__);
				return null;
  			}else{
				return m_pMixer;
			}
 		}
 
		/*****************************************************************************
		* Returns the mixer. 
		*
 		* @return \li a pointer to the mixer
 		*         \li \b 0 if no mixer was set
 		*****************************************************************************/		
		public function getAbstractMixer():CalAbstractMixer {
			return m_pMixer;
		}

		/*****************************************************************************
		* Sets the mixer to a CalAbstractMixer subclass instance.
		*
		* If a mixer was already set (with CalModel::setAbstractMixer or
		* because the CalModel::create method created a CalMixer instance),
		* its \b destroy method is called. The existing mixer is not
		* deallocated, it is the responsibility of the caller to call the
		* getAbstractMixer method and deallocate the returned instance if
		* appropriate.
		*
		* \b pMixer will be deallocated by cal3d if and only if the
		* CalModel::destroy function is called.
		*
		* The \b create method of pMixer is called.
		*
		* pMixer may be null. After setting a null pointer, the caller MUST
		* call CalModel::create or CalModel::setAbstractMixer with a non-null
		* pointer before any other method is called.
		*
		* @param pMixer is a pointer to a CalAbstractMixer subclass instance.
		*
		*****************************************************************************/		
		public function setAbstractMixer( pMixer:CalAbstractMixer ):void {
  			m_pMixer = pMixer;
		}

		/*****************************************************************************
		* Provides access to the morph target mixer.
		*
		* This function returns the morph target mixer.
		*
		* @return One of the following values:
		*         \li a pointer to the morph target mixer
		*         \li \b 0 if an error happend
		*****************************************************************************/
		public function getMorphTargetMixer():CalMorphTargetMixer {
			return m_pMorphTargetMixer;
		}

		/*****************************************************************************
		* Provides access to the physique.
		*
		* This function returns the physique.
		*
		* @return One of the following values:
		*         \li a pointer to the physique
		*         \li \b 0 if an error happend
		*****************************************************************************/
		public function getPhysique():CalPhysique {
			return m_pPhysique;
		}

		public function getRenderer():CalRenderer {
			return m_pRenderer;
		}
		
		public function getSkeleton():CalSkeleton {
			return m_pSkeleton;
		}

		public function getSpringSystem():CalSpringSystem {
			return m_pSpringSystem;
		}
		
		public function getBoundingBox( precision:Boolean = false):CalBoundingBox {
   			
   			var v:CalVector;
			v = new CalVector(1.0, 0.0, 0.0);	
			m_boundingBox.plane[0].setNormal(v);
			v = new CalVector(-1.0, 0.0, 0.0);	
			m_boundingBox.plane[1].setNormal(v);
			v = new CalVector(0.0, 1.0, 0.0);	
			m_boundingBox.plane[2].setNormal(v);
			v = new CalVector(0.0, -1.0, 0.0);	
			m_boundingBox.plane[3].setNormal(v);
			v = new CalVector(0.0, 0.0, 1.0);	
			m_boundingBox.plane[4].setNormal(v);
			v = new CalVector(0.0, 0.0,-1.0);	
			m_boundingBox.plane[5].setNormal(v);

			if(precision)
				m_pSkeleton.calculateBoundingBoxes();

	
			var vectorBone:Array =  m_pSkeleton.getVectorBone();
		
			for each(var bone:CalBone in vectorBone) {
				
				// If it's just an approximation that are needed then
				// we just compute the bounding box from the skeleton
				if(!precision || !bone.getCoreBone().isBoundingBoxPrecomputed()) {
				
					var translation:CalVector = bone.getTranslationAbsolute();
					
					var planeId:int;
					for(planeId = 0; planeId < 6; ++planeId) {
						
						if(m_boundingBox.plane[planeId].eval(translation) < 0.0) {
							
							m_boundingBox.plane[planeId].setPosition(translation);
						}
					}
					
				}else{				
					var localBoundingBox:CalBoundingBox = bone.getBoundingBox();
					
					//create array of bounding points
					var points:Array = new Array(8);
					for(var x:int = 0; x < points.length; x++){
						points[x] = new CalVector(0,0,0);
					}
					
					localBoundingBox.computePoints(points);
					
					for(var i:int = 0; i < 8; i++) {
										
						//var planeId:int;
						for(planeId = 0; planeId < 6; ++planeId) {
							
							if(m_boundingBox.plane[planeId].eval(points[i]) < 0.0) {
								
								m_boundingBox.plane[planeId].setPosition(points[i]);
							}
						}
					}				
				}
			}
	
			return m_boundingBox;
   	
		}
		
		/*****************************************************************************
		* Provides access to the user data.
		*
		* This function returns the user data stored in the model instance.
		*
		* @return The user data stored in the model instance.
		*****************************************************************************/
		public function getUserData():Object {

			return m_userData;
		}

		
		
		public function getVectorMesh():Array {
			 return m_vectorMesh;
		}
  
		public function setLodLevel( lodLevel:Number ):void {
			
			// set the lod level in all meshes
			for each(var mesh:CalMesh in m_vectorMesh ) {
				// set the lod level in the mesh
				mesh.setLodLevel(lodLevel);
			} 
  
		}
		
		public function setMaterialSet( setId:int ):void {
			
			// set the material in all meshes
			for each(var mesh:CalMesh in m_vectorMesh ) {
				// set the material set in the mesh
				mesh.setMaterialSet(setId);
			}
		}
		
		//void setUserData(Cal::UserData userData);
		public function update( deltaTime:Number ):void {
			m_pMixer.updateAnimation(deltaTime);
			m_pMixer.updateSkeleton();
			// m_pMorpher->update(...);
			m_pMorphTargetMixer.update(deltaTime);
			m_pPhysique.update();
			m_pSpringSystem.update(deltaTime);
		}
		
		public function disableInternalData():void {
			
			// Disable internal data in all meshes
			for each(var mesh:CalMesh in m_vectorMesh ) {
				// Disable internal data in the mesh
				mesh.disableInternalData();
			}	
		}
		
	}	

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalMixer extends CalAbstractMixer
	{
		protected var m_pModel:CalModel;
		protected var m_vectorAnimation:Array;
		//protected var m_listAnimationAction:ArrayCollection;
		//protected var m_listAnimationCycle:ArrayCollection;
		
		protected var m_listAnimationAction:DLinkedList;
		protected var m_listAnimationCycle:DLinkedList;
		
		protected var m_animationTime:Number;
		protected var m_animationDuration:Number;
		protected var m_timeFactor:Number;

		public function CalMixer( pModel:CalModel ){
			super();
			this.m_pModel = pModel;
			this.m_listAnimationAction = new DLinkedList();
			this.m_listAnimationCycle = new DLinkedList();
			
			//create array of nulls matching the # of animations
			//so we can dynamically test if CalAnimations are instantiated yet
			var animationCount:int = pModel.getCoreModel().getCoreAnimationCount();
			this.m_vectorAnimation = new Array(animationCount);
			
			m_animationTime = 0.0;
  			m_animationDuration = 0.0;
  			m_timeFactor = 1.0;
		}

		override public function isDefaultMixer():Boolean { 
			return true; 
		}


///
/// Examines the given animation and if the first and last keyframe of a given track
/// do not match up, the first key frame is duplicated and added to the end of the track
/// to ensure smooth looping.
///
		private function addExtraKeyframeForLoopedAnim( coreAnimation:CalCoreAnimation ):void {
			
			var listCoreTrack:Array = coreAnimation.getListCoreTrack();
			
			if(listCoreTrack.length == 0) return;

			var coreTrack:CalCoreTrack = listCoreTrack[0];
			if(coreTrack == null) return;

			var lastKeyframe:CalCoreKeyframe = coreTrack.getCoreKeyframe( coreTrack.getCoreKeyframeCount()-1 );
			if(lastKeyframe == null) return;

			if(lastKeyframe.getTime() < coreAnimation.duration ) {
				for each(var track:CalCoreTrack in listCoreTrack ){
				
					coreTrack = track;
	
					var firstKeyframe:CalCoreKeyframe = coreTrack.getCoreKeyframe(0);
	      			var newKeyframe:CalCoreKeyframe = new CalCoreKeyframe();
	
	      			newKeyframe.setTranslation( firstKeyframe.getTranslation().clone() );
					newKeyframe.setRotation( firstKeyframe.getRotation().clone() );
					newKeyframe.setTime( coreAnimation.duration );
					
	      			coreTrack.addCoreKeyframe(newKeyframe);
				}
			}
		}

		/*****************************************************************************
		* Interpolates the weight of an animation cycle.
		*
		* This function interpolates the weight of an animation cycle to a new value
		* in a given amount of time. If the specified animation cycle is not active
		* yet, it is activated.
		*
		* @param id The ID of the animation cycle that should be blended.
		* @param weight The weight to interpolate the animation cycle to.
		* @param delay The time in seconds until the new weight should be reached.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function blendCycle( id:int, weight:Number, delay:Number ):Boolean {
			var animationCycle:CalAnimationCycle
			if( (id < 0) || (id >= m_vectorAnimation.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				trace("CalMixer::blendCycle ERROR -- Invalid_Handle id:" + id + " animations:" + m_vectorAnimation.length );
				return false;
			}

			// get the animation for the given id
			var animation:CalAnimation = m_vectorAnimation[id];

			// create a new animation instance if it is not active yet
			if(animation == null) {
			
				// take the fast way out if we are trying to clear an inactive animation
				if(weight == 0.0) return true;

				// get the core animation
				var coreAnimation:CalCoreAnimation = m_pModel.getCoreModel().getCoreAnimation(id);
				if(coreAnimation == null) return false;
		
    			// Ensure that the animation's first and last key frame match for proper
    			// looping.
				addExtraKeyframeForLoopedAnim(coreAnimation);

				// allocate a new animation cycle instance
				animationCycle = new CalAnimationCycle(coreAnimation);
				
				// insert new animation into the tables
				m_vectorAnimation[id] = animationCycle;
				m_listAnimationCycle.prepend( animationCycle );

				// blend the animation
				return animationCycle.blend(weight, delay);
  			}

			// check if this is really a animation cycle instance
			if(animation.getType() != CalAnimation.TYPE_CYCLE) {
      			//CalError::setLastError(CalError::INVALID_ANIMATION_TYPE, __FILE__, __LINE__);
      			trace("CalMixer::blendCycle -- ERROR Invalid Animation Type, expected " + CalAnimation.TYPE_CYCLE + " but got " + animation.getType()  );
     			return false;
  			}

  			// clear the animation cycle from the active vector if the target weight is zero
  			if(weight == 0.0) {
      			m_vectorAnimation[id] = 0;
  			}

  			// cast it to an animation cycle
  			animationCycle = CalAnimationCycle(animation);

  			// blend the animation cycle
  			animationCycle.blend(weight, delay);
  			animationCycle.checkCallbacks(0, m_pModel);
  			return true;
		}
		
		public function clearCycle( id:int, delay:Number):Boolean {
			return true;	
		}

		/*****************************************************************************
		* Executes an animation action.
		*
		* This function executes an animation action.
		*
		* @param id The ID of the animation action that should be blended.
		* @param delayIn The time in seconds until the animation action reaches the
		*                full weight from the beginning of its execution.
		* @param delayOut The time in seconds in which the animation action reaches
		*                 zero weight at the end of its execution.
		* @param weightTarget The weight to interpolate the animation action to.
		* @param autoLock     This prevents the Action from being reset and removed
		*                     on the last keyframe if true.
		*
		* @return One of the following values:
		*         \li \b true if successful
 		*         \li \b false if an error happend
		*****************************************************************************/		
 		public function executeAction( id:int, delayIn:Number, delayOut:Number, weightTarget:Number = 1.0, autoLock:Boolean = false):Boolean {
 		
 			// get the core animation
			var coreAnimation:CalCoreAnimation = m_pModel.getCoreModel().getCoreAnimation(id);
			trace("CalMixer::executeAction -- " + coreAnimation )
  			if(coreAnimation == null) return false;

			// allocate a new animation action instance
			var animationAction:AnimationAction = new AnimationAction(coreAnimation);

			// insert new animation into the front of the table
			m_listAnimationAction.prepend(animationAction);

			// execute the animation
			animationAction.execute(delayIn, delayOut, weightTarget, autoLock);
			animationAction.checkCallbacks(0, m_pModel);
			return true;
 		}
 		
 		public function removeAction( id:int):Boolean {
 			return true;
 		}


		/*****************************************************************************
		* Updates all active animations.
		*
		* This function updates all active animations of the mixer instance for a
		* given amount of time.
		*
		* @param deltaTime The elapsed time in seconds since the last update.
		*****************************************************************************/ 		
		override public function updateAnimation( deltaTime:Number ):void {
			//trace("CalMixer::updateAnimation -- m_animationTime = " + m_animationTime);
			// update the current animation time
			if(m_animationDuration == 0.0){
				m_animationTime = 0.0;
			}else{
				m_animationTime += deltaTime * m_timeFactor;
 			if(m_animationTime >= m_animationDuration || m_animationTime<0){
      			m_animationTime = m_animationTime % m_animationDuration;
    		}
			if (m_animationTime < 0)
      			m_animationTime += m_animationDuration;
  			}
			//trace("animationtime = " + m_animationTime);

			var iteratorAnimationAction:DListIterator = m_listAnimationAction.getListIterator();
			var value:*;	
			trace(m_listAnimationAction.size);
			if(m_listAnimationAction.size > 0){
	  			while(iteratorAnimationAction.data != m_listAnimationAction.tail.data) {
	    			// update and check if animation action is still active
	    			if( iteratorAnimationAction.data.update(deltaTime)) {
	      				iteratorAnimationAction.data.checkCallbacks(iteratorAnimationAction.data.getTime(), m_pModel);
	      				iteratorAnimationAction.next();
	    			}else{
	      				// animation action has ended, destroy and remove it from the animation list
	      				iteratorAnimationAction.data.completeCallbacks(m_pModel);
	      				m_listAnimationAction.remove(iteratorAnimationAction);
	    			}
	  			}
			}
	  		// todo: update all active animation poses of this model
	
	  		// update the weight of all active animation cycles of this model
			var iteratorAnimationCycle:DListIterator = m_listAnimationCycle.getListIterator(); 
			var cycle:*;
			
	  		var accumulatedWeight:Number = 0.0;
	  		var accumulatedDuration:Number = 0.0;
	
			//iteratorAnimationCycle.start();
			//trace("CalMixer m_listAnimationCycle.size " + m_listAnimationCycle.size );

			while(cycle != m_listAnimationCycle.tail.data) {
				cycle = iteratorAnimationCycle.data;

				// update and check if animation cycle is still active
				if( cycle.update(deltaTime) ) {
				
					// check if it is in sync. if yes, update accumulated weight and duration
					if( cycle.getState() == CalAnimation.STATE_SYNC) {
						//trace("CalAnimation.STATE_SYNC");
	       	 			accumulatedWeight += cycle.getWeight();
	        			accumulatedDuration += cycle.getWeight() * cycle.getCoreAnimation().duration;
	      			}
	
	      			cycle.checkCallbacks(m_animationTime,m_pModel);
	     			iteratorAnimationCycle.next();
	     			
	    		}else{
	      			// animation cycle has ended, destroy and remove it from the animation list
	      			cycle.completeCallbacks(m_pModel);
	      			trace("Remove animationCycle");
		     		m_listAnimationCycle.remove(iteratorAnimationCycle);
	    		}
	  		}

		  // adjust the global animation cycle duration
		  if(accumulatedWeight > 0.0) m_animationDuration = accumulatedDuration / accumulatedWeight;
		  else m_animationDuration = 0.0;
  		
		}
		
		
		override public function updateSkeleton():void {

		  	// get the skeleton we need to update
			var skeleton:CalSkeleton = m_pModel.getSkeleton();
  			if(skeleton == null) return;

			// clear the skeleton state
			skeleton.clearState();

  			// get the bone vector of the skeleton
			var vectorBone:Array = skeleton.getVectorBone();

  			// loop through all animation actions
  			var animationActionIterator:DListIterator = m_listAnimationAction.getListIterator();
  			var animationAction:*
  			while(animationActionIterator.hasNext()){
			
				animationAction = animationActionIterator.next();
	    		// get the core animation instance
	    		var coreAnimation:CalCoreAnimation = animationAction.getCoreAnimation();
	
	    		// get the list of core tracks of above core animation
				var listCoreTrack:Array = coreAnimation.getListCoreTrack();
	
				// loop through all core tracks of the core animation
	 			for each(var track:CalCoreTrack in listCoreTrack) { 
	      			// get the appropriate bone of the track
	      			var bone:CalBone = vectorBone[track.getCoreBoneId()];
	
	      			// get the current translation and rotation
	       			var translation:CalVector = new CalVector();
	      			var rotation:CalQuaternion = new CalQuaternion();
	      			var results:Object = track.getState(animationAction.getTime(), translation, rotation);
				
					translation = results.t;
					rotation = results.r;
      		
	      			// blend the bone state with the new state
	      			bone.blendState(animationAction.getWeight(), translation, rotation);
	    		}
  			}

			// lock the skeleton state
  			skeleton.lockState();

			var animationCycleIterator:DListIterator = m_listAnimationCycle.getListIterator();
  			var animationCycle:*
  			while(animationCycleIterator.hasNext()){

				animationCycle = animationCycleIterator.next();

			    // get the core animation instance
			    var coreAnimation:CalCoreAnimation = animationCycle.getCoreAnimation();
			
			    var animationTime:Number;
				if(animationCycle.getState() == CalAnimation.STATE_SYNC) {
      				if(m_animationDuration == 0.0) animationTime = 0.0;
      				else animationTime = m_animationTime * (coreAnimation.duration / m_animationDuration);
      				
    			}else{
      				animationTime = animationCycle.getTime();
    			}

    			// get the list of core tracks of above core animation
				var listCoreTrack:Array = coreAnimation.getListCoreTrack();
				

				 // loop through all core tracks of the core animation
				for each(var track:CalCoreTrack in listCoreTrack){

				    // get the appropriate bone of the track
				    var bone:CalBone = vectorBone[track.getCoreBoneId()];

      				// get the current translation and rotation
	       			var translation:CalVector = new CalVector();
	      			var rotation:CalQuaternion = new CalQuaternion();
	      			
					var results:Object = track.getState(animationTime, translation, rotation);
					translation = results.t;
					rotation = results.r;
      				// blend the bone state with the new state
      				bone.blendState(animationCycle.getWeight(), translation, rotation);
    			}
 			}

	  		// lock the skeleton state
	  		skeleton.lockState();
	
	  		// let the skeleton calculate its final state
	  		skeleton.calculateState();		
		
	  		
		}
		
		/*****************************************************************************
		* Returns the animation time.
		*
		* This function returns the animation time of the mixer instance.
		*
		* @return The animation time in seconds.
		*****************************************************************************/		
 		public function getAnimationTime():Number {
 			return m_animationTime;
 		}
 		
		/*****************************************************************************
		* Returns the animation duration.
		*
		* This function returns the animation duration of the mixer instance.
		*
 		* @return The animation duration in seconds.
		*****************************************************************************/		
 		public function getAnimationDuration():Number {
 			return m_animationDuration;
 		}
 		
  		public function setAnimationTime( animationTime:Number ):void {
  			m_animationTime=animationTime;
  		}
  		
 		public function setTimeFactor( timeFactor:Number ):void {
 			m_timeFactor = timeFactor;
 		}
 		
 		public function getTimeFactor():Number {
 			return m_timeFactor;
 		}
 		
 		public function getCalModel():CalModel {
 			return m_pModel;
 		}
 		
 		public function getAnimationVector():Array {
 			return m_vectorAnimation;
 		}
 		
 		public function getAnimationActionList():Array {
 			return m_listAnimationAction.toArray(); 
 		}
 		
 		public function getAnimationCycle():Array {
 			return m_listAnimationCycle.toArray();
 		}
  
		
	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalMorphTargetMixer
	{
		private var m_vectorCurrentWeight:Array;
		private var m_vectorEndWeight:Array;
		private var m_vectorDuration:Array;
		private var m_pModel:CalModel;
	
		public function CalMorphTargetMixer( model:CalModel ):void {
			trace("CalMorphTargetMixer::CONSTRUCTOR");

			m_pModel = model;
			
			var morphAnimationCount:int = m_pModel.getCoreModel().getCoreMorphAnimationCount();
			trace("morphAnimationCount: " + morphAnimationCount);
			m_vectorCurrentWeight = new Array(morphAnimationCount);
			m_vectorEndWeight = new Array(morphAnimationCount);
			m_vectorDuration = new Array(morphAnimationCount);
			
			for(var i:int = 0; i < morphAnimationCount; i++){
				m_vectorCurrentWeight[i] = 0.0;
				m_vectorEndWeight[i] = 0.0;
				m_vectorDuration[i] = 0.0;
			}			
		}

		/*****************************************************************************
		* Interpolates the weight of a morph target.
		*
		* This function interpolates the weight of a morph target a new value
		* in a given amount of time.
		*
		* @param id The ID of the morph target that should be blended.
		* @param weight The weight to interpolate the morph target to.
		* @param delay The time in seconds until the new weight should be reached.
		*
		* @return One of the following values:
		*         \li \b true if successful
  		*         \li \b false if an error happend
		*****************************************************************************/
		public function blend( id:int, weight:Number, delay:Number ):Boolean {
			
			if((id < 0) || (id >= m_vectorCurrentWeight.length )) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}
			m_vectorEndWeight[id] = weight;
			m_vectorDuration[id] = delay;
			return true;
		}
 
		/*****************************************************************************
		* Fades a morph target out.
		*
		* This function fades a morph target out in a given amount of time.
		*
		* @param id The ID of the morph target that should be faded out.
		* @param delay The time in seconds until the the morph target is
		*              completely removed.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/ 	
		public function clear( id:int, delay:Number):Boolean {
			
			if((id < 0) || (id >= m_vectorCurrentWeight.length )) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}
			m_vectorEndWeight[id] = 0.0;
			m_vectorDuration[id] = delay;
			return true;
		}

		/*****************************************************************************
		* Get the weight of a morph target.
		*
		* @param id The id of the morph target which weight you want.
		*
		* @return The weight of the morph target with the given id.
		*****************************************************************************/		
		public function getCurrentWeight( id:int):Number {
			
			if((id < 0) || (id >= m_vectorCurrentWeight.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return 0;
			}
			return m_vectorCurrentWeight[id];
		}
		
		/*****************************************************************************
		* Get the weight of the base vertices.
		*
		* @return The weight of the base vertices.
		*****************************************************************************/	
		public function getCurrentWeightBase():Number {
			
			var currentWeight:Number = 1.0;

			for(var i:int = 0; i < m_vectorCurrentWeight.length; i++){
				currentWeight -= m_vectorCurrentWeight[i];
			}
			
			return currentWeight;
		}
		
		/*****************************************************************************
		* Returns the number of morph targets this morph target mixer mixes.
		*
		* @return The number of morph targets this morph target mixer mixes.
		*****************************************************************************/	
		public function getMorphTargetCount():int {
			return m_vectorCurrentWeight.length;
		}

		/*****************************************************************************
		* Updates all morph targets.
		*
		* This function updates all morph targets of the mixer instance for a
		* given amount of time.
		*
		* @param deltaTime The elapsed time in seconds since the last update.
		*****************************************************************************/		
		public function update( deltaTime:Number ):void {
			
	  		var iteratorCurrentWeight:Number = m_vectorCurrentWeight[0];
	  		var iteratorEndWeight:Number = m_vectorEndWeight[0];
	  		var iteratorDuration:Number = m_vectorDuration[0];
	  
	  		for(var i:int = 0; i < m_vectorCurrentWeight.length; i++){
	
	    		if(deltaTime >= iteratorDuration) {
	      			iteratorCurrentWeight = iteratorEndWeight;
	      			iteratorDuration = 0.0;
	    		}else{
	      			iteratorCurrentWeight += ( iteratorEndWeight - iteratorCurrentWeight ) *
	                                  deltaTime / iteratorDuration ;
	      			iteratorDuration -= deltaTime;
	    		}
	   			iteratorCurrentWeight = m_vectorCurrentWeight[i];
	    		iteratorEndWeight = m_vectorEndWeight[i];
	    		iteratorDuration = m_vectorDuration[i];
	  		}
  
  		 // trace("morph target count: " + getMorphTargetCount() );
		  var morphAnimationID:int = 0;
		  while(morphAnimationID < getMorphTargetCount())
		  {
		    var pCoreMorphAnimation:CalCoreMorphAnimation = 
		                   m_pModel.getCoreModel().getCoreMorphAnimation(morphAnimationID);
		    var vectorCoreMeshID:Array = pCoreMorphAnimation.getVectorCoreMeshID();
		    var vectorMorphTargetID:Array = pCoreMorphAnimation.getVectorMorphTargetID();
		    var meshIterator:int = 0;
		    trace("CalMorphTargetMixer::update() -- vetorCoreMoeshID.length " + vectorCoreMeshID.length);
		    while(meshIterator < vectorCoreMeshID.length)
		    {
		       	var vectorSubmesh:Array = 
		             m_pModel.getMesh(vectorCoreMeshID[meshIterator]).getVectorSubmesh();
		       var submeshCount:int = vectorSubmesh.length;
		       
		       var submeshId:int;
		       for(submeshId=0; submeshId < submeshCount; ++submeshId) {
		         
		         vectorSubmesh[submeshId].setMorphTargetWeight 
		                  (vectorMorphTargetID[meshIterator], m_vectorCurrentWeight[morphAnimationID]);
		         trace("setting morph target weight to " + vectorMorphTargetID[meshIterator] + " " +  m_vectorCurrentWeight[morphAnimationID]);
		       }
		       ++meshIterator;
		    }
		    ++morphAnimationID;
		  }

			
		}



	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalPhysique
	{
		private var m_pModel:CalModel
		private var m_Normalize:Boolean;
		private var m_axisFactorX:Number;
		private var m_axisFactorY:Number;
		private var m_axisFactorZ:Number;
		
		public function CalPhysique( pModel:CalModel ):void {
			
			m_Normalize = true;
			m_pModel = pModel;
			m_axisFactorX = 1.0;
			m_axisFactorY = 1.0;
 			m_axisFactorZ = 1.0;
		}
				
		public function calculateTangentSpaces(pSubmesh:CalSubmesh, mapId:int, pTangentSpaceBuffer:Number, stride:int = 0):int {
		
		return -1;	
		}
		
		public function calculateNormals( pSubmesh:CalSubmesh, pNormalBuffer:Number, stride:int = 0):int {
		
			return -1;		
		}


		/*****************************************************************************
		* Calculates the transformed vertex data.
  		*
  		* This function calculates and returns the transformed vertex data of a
  		* specific submesh.
  		*
  		* @param pSubmesh A pointer to the submesh from which the vertex data should
  		*                 be calculated and returned.
  		* @param pVertexBuffer A pointer to the user-provided buffer where the vertex
  		*                      data is written to.
  		*
  		* @return The number of vertices written to the buffer.
  		*****************************************************************************/		
		/*
		public function calculateVertices( pSubmesh:CalSubmesh, stride:int = 0):Array {
			//print("Calculating Vertices!");
	  		// get bone vector of the skeleton
			var vectorBone:Array = m_pModel.getSkeleton().getVectorBone();
			//print("Got Bone array!");
	 		// get vertex vector of the core submesh
			var vectorVertex:Array = pSubmesh.getCoreSubmesh().getVectorVertex();
			//print("Calculating Vertices: Len - "+ vectorVertex.length);
			//trace("CalPhysique::calculateVertices: " + vectorVertex.length);
	  		// get physical property vector of the core submesh
			var vectorPhysicalProperty:Array = pSubmesh.getCoreSubmesh().getVectorPhysicalProperty();
			//print("Get Phys Properties!");
	  		// get the number of vertices
	  		var vertexCount:int = pSubmesh.getVertexCount();
			//print("Vert Count"+vertexCount);
	  		// get the sub morph target vector from the core sub mesh
			var vectorSubMorphTarget:Array = pSubmesh.getCoreSubmesh().getVectorCoreSubMorphTarget();
			//print("Morph Array!");
	  		// calculate the base weight
			var baseWeight:Number = pSubmesh.getBaseWeight();
			//print("Calc Weight!");
	  		// get the number of morph targets
			var morphTargetCount:int = pSubmesh.getMorphTargetWeightCount();
			//print("Morph Count!!");
			
	
			var vertexBuffer:Array = new Array(vertexCount);
			//print("Create New Array");
			//trace("CalPhysique::update()");
			//trace("baseWeight: " + baseWeight );
			//trace("morphTargetCount: " + morphTargetCount);
	
			// calculate all submesh vertices
	  		var vertexId:int;

	  		for(vertexId = 0; vertexId < vertexCount; ++vertexId) {
	    		
	    		// get the vertex
	    		var vertex:Vertex = vectorVertex[vertexId];
	    	
				// blend the morph targets
	    		var position:CalVector = new CalVector(0,0,0);
	    		if(baseWeight == 1.0) {
	       			position.x = vertex.position.x;
	       			position.y = vertex.position.y;
	       			position.z = vertex.position.z;
	    
	    		}else{
	      			position.x = baseWeight*vertex.position.x;
	      			position.y = baseWeight*vertex.position.y;
	      			position.z = baseWeight*vertex.position.z;
	      			var morphTargetId:int;
	      			for(morphTargetId=0; morphTargetId < morphTargetCount;++morphTargetId){
	       	 			var blendVertex:BlendVertex =
	        				vectorSubMorphTarget[morphTargetId].getVectorBlendVertex()[vertexId];
	       				var currentWeight:int = pSubmesh.getMorphTargetWeight(morphTargetId);
	        			position.x += currentWeight*blendVertex.position.x;
	        			position.y += currentWeight*blendVertex.position.y;
	        			position.z += currentWeight*blendVertex.position.z;
	     			}
	    		}
	
	    		// initialize vertex
	    		var x:Number = 0.0;
	    		var y:Number = 0.0;
	    		var z:Number= 0.0;
	
	    		// blend together all vertex influences
	    		
	    		
	    		
	    		var influenceCount:int = vertex.vectorInfluence.length;
	    		//print("Calc Influences");
	    		//trace("calcualting influence: influenceCount "  + influenceCount);
	    		
	    		if(influenceCount == 0){
	    			//trace("influenece == 0");
	    			x = position.x;
	     		 	y = position.y;
	      			z = position.z;
	    		
	    		}else{
	    			
					for(var influenceId:int = 0; influenceId < influenceCount; ++influenceId){
						// get the influence
						var influence:Influence = vertex.vectorInfluence[influenceId];
						//trace(influence);
						//	trace("INFLUENCE: weight " + influence.weight + " boneId " + influence.boneId );
						// get the bone of the influence vertex
						var pBone:CalBone = vectorBone[influence.boneId];
					
						// transform vertex with current state of the bone
						var v:CalVector = new CalVector(position.x, position.y, position.z);
						
						//trace("Vertex pre-Matrix: " + v.x + " " + v.y + " " + v.z);
						
						v.multiplyByMatrix(pBone.getTransformMatrix() );
						v.add(pBone.getTranslationBoneSpace() );
						
						//trace("Vertex post-Matrix: " + v.x + " " + v.y + " " + v.z);
						//trace("influence weight: " + influence.weight + " boneId: " + influence.boneId);
						
						x += influence.weight * v.x;
						y += influence.weight * v.y;
						z += influence.weight * v.z;
						//trace("Vertex xyz: " + x + " " + y + " " + z);
					}
				}
			
				
				var tvertex:CalVector = new CalVector(0,0,0);
				var transformedVertex:Vertex = vertex.clone();
				
		    	// save vertex position
		    	if(pSubmesh.getCoreSubmesh().getSpringCount() > 0 && pSubmesh.hasInternalData()){
					// get the pgysical property of the vertex
					var physicalProperty:PhysicalProperty = vectorPhysicalProperty[vertexId];
		
					// assign new vertex position if there is no vertex weight
		      		if(physicalProperty.weight == 0.0){
		        		tvertex.x = x * m_axisFactorX;
		        		tvertex.y = y * m_axisFactorY;
		        		tvertex.z = z * m_axisFactorZ;
		      		}
		      		
				}else{
					
		     		tvertex.x = x * m_axisFactorX;
		      		tvertex.y = y * m_axisFactorY;
		      		tvertex.z = z * m_axisFactorZ;
		  		}
		  		
		  		
		  		transformedVertex.position.x = tvertex.x ;
		  		transformedVertex.position.y = tvertex.y ;
		  		transformedVertex.position.z = tvertex.z ;
		  		
		  		vertexBuffer[vertexId] = transformedVertex;
		  		
		  	}
			//print("Return Buffer!");
			return vertexBuffer;	
		}
		*/
		
		public function calculateVertices( pSubmesh:CalSubmesh, stride:int = 0):Array {
			//print("Calculating Vertices!");
	  		// get bone vector of the skeleton
			if(m_pModel.getSkeleton()!=null)
			{
				//print("Skeleton not null!");
			}
			var vectorBone:Array = m_pModel.getSkeleton().getVectorBone();
			//print("Get Bone array: "+ vectorBone.length);
	 		// get vertex vector of the core submesh
			var vectorVertex:Array = pSubmesh.getCoreSubmesh().getVectorVertex();
			//print("Got vertices??!" + vectorVertex.length);
			//trace("CalPhysique::calculateVertices: " + vectorVertex.length);
	  		// get physical property vector of the core submesh
			var vectorPhysicalProperty:Array = pSubmesh.getCoreSubmesh().getVectorPhysicalProperty();
			//print("Got Phys Property!");
	  		// get the number of vertices
	  		var vertexCount:int = pSubmesh.getVertexCount();
			
	  		// get the sub morph target vector from the core sub mesh
			var vectorSubMorphTarget:Array = pSubmesh.getCoreSubmesh().getVectorCoreSubMorphTarget();
	
	  		// calculate the base weight
			var baseWeight:Number = pSubmesh.getBaseWeight();
	
	  		// get the number of morph targets
			var morphTargetCount:int = pSubmesh.getMorphTargetWeightCount();
	
			
	
			var vertexBuffer:Array = new Array(vertexCount);
			//print("New vert array!");
			//trace("CalPhysique::update()");
			//trace("baseWeight: " + baseWeight );
			//trace("morphTargetCount: " + morphTargetCount);
	
			// calculate all submesh vertices
	  		var vertexId:int = 0;

	  		for each(var vertex:Vertex in vectorVertex) {
	    		
				// blend the morph targets
	    		var position:CalVector = new CalVector(0,0,0);
	    		if(baseWeight == 1.0) {
	       			position.x = vertex.position.x;
	       			position.y = vertex.position.y;
	       			position.z = vertex.position.z;
	    
	    		}else{
	      			position.x = baseWeight*vertex.position.x;
	      			position.y = baseWeight*vertex.position.y;
	      			position.z = baseWeight*vertex.position.z;
	      			var morphTargetId:int;
	      			for(morphTargetId=0; morphTargetId < morphTargetCount;++morphTargetId){
	       	 			var blendVertex:BlendVertex =
	        				vectorSubMorphTarget[morphTargetId].getVectorBlendVertex()[vertexId];
	       				var currentWeight:int = pSubmesh.getMorphTargetWeight(morphTargetId);
	        			position.x += currentWeight*blendVertex.position.x;
	        			position.y += currentWeight*blendVertex.position.y;
	        			position.z += currentWeight*blendVertex.position.z;
	     			}
	    		}
	
	    		// initialize vertex
	    		var x:Number = 0.0;
	    		var y:Number = 0.0;
	    		var z:Number= 0.0;
	
	    		// blend together all vertex influences
	    		
	    		//print("Blending Verts");
	    		
	    		var influenceCount:int = vertex.vectorInfluence.length;
	    		
	    		//trace("calcualting influence: influenceCount "  + influenceCount);
	    		//print("Calc Influences!");
	    		if(influenceCount == 0){
	    			//trace("influenece == 0");
	    			x = position.x;
	     		 	y = position.y;
	      			z = position.z;
	    		
	    		}else{
	    			
					for(var influenceId:int = 0; influenceId < influenceCount; ++influenceId){
						// get the influence
						//print("Getting Influences");
						var influence:Influence = vertex.vectorInfluence[influenceId];
						//print("Getting Bone #"+influence.boneId);
						// get the bone of the influence vertex
						var pBone:CalBone = vectorBone[influence.boneId];
						//print("Transforming");
						// transform vertex with current state of the bone
						var v:CalVector = new CalVector(position.x, position.y, position.z);
						//print("Multiply Matrix");
						v.multiplyByMatrix(pBone.getTransformMatrix() );
						v.add(pBone.getTranslationBoneSpace() );
						//print("Translate");
						x += influence.weight * v.x;
						y += influence.weight * v.y;
						z += influence.weight * v.z;
	
					}
				}
			
				
				var tvertex:CalVector = new CalVector(0,0,0);
				//print("Cloning");
				var transformedVertex:Vertex = vertex.clone();
				//print("Saving Position");
		    	// save vertex position
		    	if(pSubmesh.getCoreSubmesh().getSpringCount() > 0 && pSubmesh.hasInternalData()){
					// get the physical property of the vertex
					var physicalProperty:PhysicalProperty = vectorPhysicalProperty[vertexId];
		
					// assign new vertex position if there is no vertex weight
		      		if(physicalProperty.weight == 0.0){
		        		tvertex.x = x * m_axisFactorX;
		        		tvertex.y = y * m_axisFactorY;
		        		tvertex.z = z * m_axisFactorZ;
		      		}
		      		
				}else{
					
		     		tvertex.x = x * m_axisFactorX;
		      		tvertex.y = y * m_axisFactorY;
		      		tvertex.z = z * m_axisFactorZ;
		  		}
		  		
		  		
		  		transformedVertex.position.x = tvertex.x ;
		  		transformedVertex.position.y = tvertex.y ;
		  		transformedVertex.position.z = tvertex.z ;
		  		
		  		vertexBuffer[vertexId] = transformedVertex;
				//print("Next Vert: "+vertexId);
		  		++vertexId;
		  	}
			//print("Return Array");
			return vertexBuffer;	
		}
		
		
 		public function calculateVertex( pSubmesh:CalSubmesh, vertexId:int ):CalVector{
 			
 				return null;	
 		}
 		
		public function calculateVerticesAndNormals( pSubmesh:CalSubmesh, pVertexBuffer:Number, stride:int=0 ):int {
				return -1;	
		}
		
		public function calculateVerticesNormalsAndTexCoords( pSubmesh:CalSubmesh, pVertexBuffer:Number, NumTexCoords:int = 1):int {  
				return -1;	
		}
		
		public function update():void {
			
			 // get the attached meshes vector
			var vectorMesh:Array = m_pModel.getVectorMesh();

  			// loop through all the attached meshes
		 	for each(var mesh:CalMesh in vectorMesh){
    			// get the submesh vector of the mesh
 				var vectorSubmesh:Array = mesh.getVectorSubmesh();

				// loop through all the submeshes of the mesh
				for each(var subMesh:CalSubmesh in vectorSubmesh){
					// check if the submesh handles vertex data internally
					if(subMesh.hasInternalData()) {
						// calculate the transformed vertices and store them in the submesh
						var vectorVertex:Array = subMesh.getVectorVertex();
						calculateVertices(subMesh, 0);
						/*
						// calculate the transformed normals and store them in the submesh
						std::vector<CalVector>& vectorNormal = (*iteratorSubmesh)->getVectorNormal();
						calculateNormals(*iteratorSubmesh, (float *)&vectorNormal[0]);

						unsigned mapId;
						for(mapId=0;mapId< (*iteratorSubmesh)->getVectorVectorTangentSpace().size();mapId++) {
							if((*iteratorSubmesh)->isTangentsEnabled(mapId)) {
					            std::vector<CalSubmesh::TangentSpace>& vectorTangentSpace = (*iteratorSubmesh)->getVectorVectorTangentSpace()[mapId];
					            calculateTangentSpaces(*iteratorSubmesh, mapId,(float *)&vectorTangentSpace[0]);
          					}
        				}
						*/
      				}
    			}
  			}
  			
		}
			

		public function setNormalization( normalize:Boolean ):void {
			
		}
		
 		public function setAxisFactorX( factor:Number):void {
 			
 		}
 		
		public function setAxisFactorY( factor:Number ):void {
			
		}
		
		public function setAxisFactorZ( factor:Number ):void {
			
		}


	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalSpringSystem
	{
		private var m_pModel:CalModel;
		private var m_vGravity:CalVector; 
		private var m_vForce:CalVector;  
		private var m_collision:Boolean;	
		
		public function CalSpringSystem( pModel:CalModel ):void {

		}

		public function calculateForces( pSubmesh:CalSubmesh, deltaTime:Number ):void {
			
		}
		
		public function calculateVertices( pSubmesh:CalSubmesh, deltaTime:Number ):void {
			
		}
		
		public function update( deltaTime:Number ):void {
			
		}
  
		public function getGravityVector():CalVector {
			return m_vGravity;
		}
		
		public function setGravityVector( vGravity:CalVector ):void {
			m_vGravity = vGravity;
		}
		
		public function getForceVector():CalVector {
			return m_vForce;
		}
		
		public function setForceVector( vForce:CalVector ):void {
			m_vForce = vForce;
		}
		
		public function setCollisionDetection( collision:Boolean ):void {
			m_collision=collision;
		}

	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalRenderer
	{
		private var m_pModel:CalModel;
		private var m_pSelectedSubmesh:CalSubmesh;
		private var _selectedMeshName:String;
		
		public function CalRenderer( pModel:CalModel ):void {
		  m_pModel = pModel;
		}

		public function beginRendering():Boolean {
			
			// get the attached meshes vector
			var vectorMesh:Array = m_pModel.getVectorMesh();

			// check if there are any meshes attached to the model
			if(vectorMesh.length == 0) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}

			// select the default submesh
			m_pSelectedSubmesh = vectorMesh[0].getSubmesh(0);
			_selectedMeshName = vectorMesh[0].getCoreMesh().getName();
			
			if(m_pSelectedSubmesh == null) return false;
			
			  return true;
		}
		
		
		public function endRendering():void {
			// clear selected submesh
			m_pSelectedSubmesh = null
		}
		
		public function getAmbientColor( pColorBuffer:Array ):void {
			/*
			// get the core material
			var pCoreMaterial:CalCoreMaterial;
			pCoreMaterial = m_pModel->getCoreModel().getCoreMaterial(m_pSelectedSubmesh.getCoreMaterialId());
			if(pCoreMaterial == 0) {
				// write default values to the color buffer
				pColorBuffer[0] = 0;
				pColorBuffer[1] = 0;
				pColorBuffer[2] = 0;
				pColorBuffer[3] = 0;

				return;
  			}

			// get the ambient color of the material
			CalCoreMaterial::Color& color = pCoreMaterial.getAmbientColor();

			// write it to the color buffer
			pColorBuffer[0] = color.red;
			pColorBuffer[1] = color.green;
			pColorBuffer[2] = color.blue;
			pColorBuffer[3] = color.alpha;
			*/
		}
		
		public function getDiffuseColor( pColorBuffer:Array ):void {
			
		}

		/*****************************************************************************
		* Returns the number of faces.
		*
		* This function returns the number of faces in the selected mesh/submesh.
		*
		* @return The number of faces.
		*****************************************************************************/		
		public function getFaceCount():int {
			return m_pSelectedSubmesh.getFaceCount();
		}

		/*****************************************************************************
		* Provides access to the face data.
		*
		* This function returns the face data (vertex indices) of the selected
		* mesh/submesh. The LOD setting is taken into account.
		*
		* @param pFaceBuffer A pointer to the user-provided buffer where the face
		*                    data is written to.
		*
		* @return The number of faces written to the buffer.
		*****************************************************************************/		
		public function getFaces():Array {
			return m_pSelectedSubmesh.getFaces();
		}

 		/*****************************************************************************
		* Returns the number of maps.
		*
		* This function returns the number of maps in the selected mesh/submesh.
		*
  		* @return The number of maps.
		*****************************************************************************/		
		public function getMapCount():int {
			/*
			// get the core material
 			var pCoreMaterial:CalCoreMaterial;
			pCoreMaterial = m_pModel.getCoreModel().getCoreMaterial(m_pSelectedSubmesh.getCoreMaterialId());
			if(pCoreMaterial == 0) return 0;

			return pCoreMaterial.getMapCount();
			*/
			return -1;
		}

		/*****************************************************************************
		* Provides access to a specified map user data.
		*
		* This function returns the user data stored in the specified map of the
 		* material of the selected mesh/submesh.
		*
		* @param mapId The ID of the map.
		*
		* @return One of the following values:
		*         \li the user data stored in the specified map
		*         \li \b 0 if an error happend
		*****************************************************************************/
		public function getMapUserData( mapId:int ):Object {
			return null;
			
		}	
 
		/*****************************************************************************
		* Returns the number of attached meshes.
		*
		* This function returns the number of meshes attached to the renderer
 		* instance.
		*
  		* @return The number of attached meshes.
  		*****************************************************************************/ 
		public function getMeshCount():int {
			  // get the attached meshes vector
 			var vectorMesh:Array = m_pModel.getVectorMesh();
			return vectorMesh.length;
		}

		/*****************************************************************************
		* Provides access to the normal data.
		*
		* This function returns the normal data of the selected mesh/submesh.
		*
		* @param pNormalBuffer A pointer to the user-provided buffer where the normal
		*                      data is written to.
		*
		* @return The number of normals written to the buffer.
		*****************************************************************************/		
		public function getNormals( stride:int = 0):Array {

			// check if the submesh handles vertex data internally
			if(m_pSelectedSubmesh.hasInternalData()) {
		
				// get the normal vector of the submesh
				var vectorNormal:Array = m_pSelectedSubmesh.getVectorNormal();

				// get the number of normals (= number of vertices) in the submesh
    			var normalCount:int = m_pSelectedSubmesh.getVertexCount();
			
				return vectorNormal;
			/*

				// copy the internal normal data to the provided normal buffer
				if(stride == sizeof(CalVector) || stride <= 0) {
					
					memcpy(pNormalBuffer, &vectorNormal[0], normalCount * sizeof(CalVector));
				
				}else{
					
					char * pBuffer = (char*) pNormalBuffer;
					for(int i=0; i < normalCount; ++i) {
						memcpy(&pBuffer[0], &vectorNormal[i], sizeof(CalVector));
						pBuffer+=stride;
					}

				}
				
				return normalCount;
				*/
			}

			return null;
			// submesh does not handle the vertex data internally, so let the physique calculate it now
			//return m_pModel.getPhysique().calculateNormals(m_pSelectedSubmesh, pNormalBuffer, stride);

		}

		/*****************************************************************************
		* Returns the shininess factor.
 		*
		* This function returns the shininess factor of the material of the selected
		* mesh/submesh..
		*
		* @return The shininess factor.
		*****************************************************************************/		
		public function getShininess():Number {
			
			return 0.50;
			/*
			// get the core material
			var pCoreMaterial:CalCoreMaterial;
			pCoreMaterial = m_pModel.getCoreModel().getCoreMaterial(m_pSelectedSubmesh.getCoreMaterialId());
			if(pCoreMaterial == 0) return 50.0;

			return pCoreMaterial.getShininess();
			*/
		}

		/*****************************************************************************
		* Provides access to the specular color.
		*
		* This function returns the specular color of the material of the selected
		* mesh/submesh.
		*
		* @param pColorBuffer A pointer to the user-provided buffer where the color
		*                     data is written to.
		*****************************************************************************/		
		public function getSpecularColor( pColorBuffer:Array ):void {
		/*	
			// get the core material
			var pCoreMaterial:CalCoreMaterial;
			pCoreMaterial = m_pModel.getCoreModel().getCoreMaterial(m_pSelectedSubmesh.getCoreMaterialId());
			if(pCoreMaterial == 0) {
			    // write default values to the color buffer
			    pColorBuffer[0] = 255;
			    pColorBuffer[1] = 255;
			    pColorBuffer[2] = 255;
			    pColorBuffer[3] = 0;
			 	
			 	return;
			}
	
	  		// get the specular color of the material
	  		CalCoreMaterial::Color& color = pCoreMaterial->getSpecularColor();
	
	  		// write it to the color buffer
			pColorBuffer[0] = color.red;
			pColorBuffer[1] = color.green;
			pColorBuffer[2] = color.blue;
			pColorBuffer[3] = color.alpha;
		*/
		}

		/*****************************************************************************
		* Returns the number of submeshes.
		*
		* This function returns the number of submeshes in a given mesh.
		*
		* @param meshId The ID of the mesh for which the number of submeshes should
		*               be returned..
		*
		* @return The number of submeshes.
		*****************************************************************************/		
		public function getSubmeshCount( meshId:int ):int {
			// get the attached meshes vector
			var vectorMesh:Array = m_pModel.getVectorMesh();

			// check if the mesh id is valid
	 		if((meshId < 0) || (meshId >= vectorMesh.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return 0;
	 		}
	
			return vectorMesh[meshId].getSubmeshCount();
		}

		/*****************************************************************************
		* Provides access to the texture coordinate data.
		*
		* This function returns the texture coordinate data for a given map of the
		* selected mesh/submesh.
		*
 		* @param mapId The ID of the map to get the texture coordinate data from.
		* @param pTextureCoordinateBuffer A pointer to the user-provided buffer where
		*                    the texture coordinate data is written to.
		*
		* @return The number of texture coordinates written to the buffer.
		*****************************************************************************/		
		public function getTextureCoordinates( mapId:int, pTextureCoordinateBuffer:Array, stride:int = 0):int {
			return 1;
		}
		
		/*****************************************************************************
		* Returns the number of vertices.
		*
		* This function returns the number of vertices in the selected mesh/submesh.
		*
		* @return The number of vertices.
 		*****************************************************************************/		
		public function getVertexCount():int {
			return m_pSelectedSubmesh.getVertexCount();
		}
		
		/*****************************************************************************
		* Provides access to the vertex data.
  		*
		* This function returns the vertex data of the selected mesh/submesh.
		*
		* @param pVertexBuffer A pointer to the user-provided buffer where the vertex
		*                      data is written to.
 		*
		* @return The number of vertices written to the buffer.
		*****************************************************************************/		
		public function getVertices( stride:int = 0 ):Array {
			//trace("CalRenderer:getVertices -- " + m_pSelectedSubmesh.hasInternalData() );
			// check if the submesh handles vertex data internally
			
			if(m_pSelectedSubmesh.hasInternalData()) {
				//print("Fetcing verts!");
				// get the vertex vector of the submesh
				var vectorVertex:Array = m_pSelectedSubmesh.getVectorVertex();
				//print("Have Array!");
				// get the number of vertices in the submesh
				var vertexCount:int = m_pSelectedSubmesh.getVertexCount();
				return vectorVertex;
  			}else{
				//print("Calc Physique?!");
				if(m_pModel!=null)
				{
					//print("Pmodel not null");
				}
				if(m_pModel.getPhysique()!=null)
				{
					//print("Physique not null");
				}
				// submesh does not handle the vertex data internally, so let the physique calculate it now
				var vectorVertex:Array = m_pModel.getPhysique().calculateVertices(m_pSelectedSubmesh, stride);
				return vectorVertex;
  			}
		}

		public function getVerticesf( verts:Array,stride:int = 0 ):Number {
			//trace("CalRenderer:getVertices -- " + m_pSelectedSubmesh.hasInternalData() );
			// check if the submesh handles vertex data internally
			if(m_pSelectedSubmesh.hasInternalData()) {
				// get the vertex vector of the submesh
				var vectorVertex:Array = m_pSelectedSubmesh.getVectorVertex();
				//print("UM!");
				var vertexId:int;
				for(vertexId = 0; vertexId <= vectorVertex.length - 1; vertexId+=3) {
					verts[vertexId] =  vectorVertex[vertexId].position.x;
					verts[vertexId+1] =  vectorVertex[vertexId].position.y;
					verts[vertexId+2] =  vectorVertex[vertexId].position.z;
				}				
				
				// get the number of vertices in the submesh
				var vertexCount:int = m_pSelectedSubmesh.getVertexCount();
				return vertexCount;
  			}else{
				// submesh does not handle the vertex data internally, so let the physique calculate it now
				var vectorVertex:Array = m_pModel.getPhysique().calculateVertices(m_pSelectedSubmesh, stride);
				var vertexId:int;
				//print("OOF!");
				for(vertexId = 0; vertexId <= vectorVertex.length - 1; vertexId+=3) {
					verts[vertexId] =  vectorVertex[vertexId].position.x;
					verts[vertexId+1] =  vectorVertex[vertexId].position.y;
					verts[vertexId+2] =  vectorVertex[vertexId].position.z;
				}				
				
				// get the number of vertices in the submesh
				var vertexCount:int = m_pSelectedSubmesh.getVertexCount();
				return vertexCount;				
  			}
		}

		
		
		/*****************************************************************************
		* Provides access to the tangent space data.
		*
		* This function returns the tangent space data of the selected mesh/submesh.
		*
		* @param mapID
		*
		* @param pTangentSpaceBuffer A pointer to the user-provided buffer where the normal
		*                      data is written to.
		*
		* @return The number of tangent space written to the buffer.
		*****************************************************************************/
		public function getTangentSpaces( mapId:int, pTangentSpaceBuffer:Array, stride:int = 0):int {
			
			return 1;
			
		}
		
		
		//NOT CORRECT
		public function getVerticesAndNormals( pVertexBuffer:Array, stride:int = 0):int {
			
			// check if the submesh handles vertex data internally
			if(m_pSelectedSubmesh.hasInternalData()) {
			    // get the vertex vector of the submesh
			    var vectorVertex:Array = m_pSelectedSubmesh.getVectorVertex();
				// get the normal vector of the submesh
			    var vectorNormal:Array = m_pSelectedSubmesh.getVectorNormal();
			    
			    // get the number of vertices in the submesh
			    var vertexCount:int = m_pSelectedSubmesh.getVertexCount();
	
				//if(stride <= 0) stride = 6*sizeof(float);
	
				return vertexCount;
 			}
			
			  // submesh does not handle the vertex data internally, so let the physique calculate it now
			  return m_pModel.getPhysique().calculateVerticesAndNormals(m_pSelectedSubmesh, stride);

		}
		
		public function getVerticesNormalsAndTexCoords( pVertexBuffer:Array, NumTexCoords:int = 1):int {
			
			return 1;
		}
		
		/*****************************************************************************
		* Returns if tangent are enabled.
		*
		* This function returns if tangent of the current submesh are enabled
 		*
		* @return True is tangent is enabled.
		*****************************************************************************/	
		public function isTangentsEnabled( mapId:int ):Boolean {
			return m_pSelectedSubmesh.isTangentsEnabled(mapId);
		}
		
		/*****************************************************************************
		* Selects a mesh/submesh for rendering data queries.
		*
		* This function selects a mesh/submesh for further rendering data queries.
		*
		* @param meshId The ID of the mesh that should be used for further rendering
		*               data queries.
		* @param submeshId The ID of the submesh that should be used for further
		*                  rendering data queries.
		*
		* @return One of the following values:
		*         \li \b true if successful
		*         \li \b false if an error happend
		*****************************************************************************/		
		public function selectMeshSubmesh( meshId:int, submeshId:int ):Boolean {
			 
			 // get the attached meshes vector
			var vectorMesh:Array = m_pModel.getVectorMesh();

			// check if the mesh id is valid
			if((meshId < 0) || (meshId >= vectorMesh.length)) {
				//CalError::setLastError(CalError::INVALID_HANDLE, __FILE__, __LINE__);
				return false;
			}

			// get the core submesh
			m_pSelectedSubmesh = vectorMesh[meshId].getSubmesh(submeshId);
 			if(m_pSelectedSubmesh == null) return false;

			//set name
			_selectedMeshName = vectorMesh[meshId].getCoreMesh().getName();
			
			return true;
		}
		
		public function get selectedMeshName():String {
			return _selectedMeshName;
		}
		
		public function setNormalization( normalize:Boolean ):void {
			
			m_pModel.getPhysique().setNormalization(normalize); 
		}




	}

/**
 * ActionScript Cal3D
 * 2008 ActionScript port by Jason Fries
 * Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger
 * 			
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.  
 */
class CalLoader extends URLLoader
	{	
		public static var LOADER_ROTATE_X_AXIS:int = 1;
		public static var LOADER_INVERT_V_COORD:int = 2;
		public static var LOADER_FLIP_WINDING:int = 4;
		
		//we need the skeleton to define animations and meshes
		private var skeleton:CalCoreSkeleton;
		private var loadingMode:int;
		
		//load item at this id
		private var assetId:int = -1;
		private var assetName:String;
		
		public function CalLoader(loadingMode:int = 0) {
			super();
			this.loadingMode = loadingMode;
		}
		
	   /*****************************************************************************
		* Loads a core skeleton instance.
		*
		* This function loads a core skeleton instance from a file.
		*
		* @param strFilename The file to load the core skeleton instance from.
		*
		* @return One of the following values:
		*         \li a pointer to the core skeleton
		*         \li \b 0 if an error happened
		*****************************************************************************/
		public function loadCoreSkeleton( filename:String ):void {

			//validate file extension
			trace(filename);
	
			var ext:String =  filename.substring(filename.length-3, filename.length).toUpperCase();
			trace("CalLoader: extension = " + ext );
			if( (filename.length >= 3) && (ext == CalConstant.SKELETON_XMLFILE_EXTENSION) ) {
				
				this.addEventListener(Event.COMPLETE, loadXmlCoreSkeleton); //wait for XML file to completely download
				this.load(new URLRequest(filename));			
			}else{
				//binary cal3d files not yet supported
				trace("CalLoader: binary cal3d files (CSF) not yet supported");
			}
			return;
			
		}
		
	   /*****************************************************************************
		* Loads a core mesh instance.
		*
		* This function loads a core mesh instance from a file.
		*
		* @param strFilename The file to load the core mesh instance from.
		*
		* @return One of the following values:
		*         \li a pointer to the core mesh
		*         \li \b 0 if an error happened
		*****************************************************************************/
		public function loadCoreMesh( filename:String ):void {

			//validate file extension
			trace(filename);
	
			var ext:String =  filename.substring(filename.length-3, filename.length).toUpperCase();
			trace("CalLoader: extension = " + ext );
			if( (filename.length >= 3) && (ext == CalConstant.MESH_XMLFILE_EXTENSION) ) {
				
				this.addEventListener(Event.COMPLETE, loadXmlCoreMesh); //wait for XML file to completely download
				this.load(new URLRequest(filename));			
			}else{
				//binary cal3d files not yet supported
				trace("CalLoader: binary cal3d files (CRF) not yet supported");
			}
			return;
			
		}		

		public function loadCoreMeshByName( filename:String, meshName:String ):void {

			trace(filename);
			//validate file extension
			var ext:String =  filename.substring(filename.length-3, filename.length).toUpperCase();
			
			if( (filename.length >= 3) && (ext == CalConstant.MESH_XMLFILE_EXTENSION) ) {
				
				this.assetName = meshName;
				this.addEventListener(Event.COMPLETE, loadXmlCoreMesh); //wait for XML file to completely download
				this.load(new URLRequest(filename));
							
			}else{
				//binary cal3d files not yet supported
				trace("CalLoader: binary cal3d files (CRF) not yet supported");
			}
			return;
			
		}
		
		/*****************************************************************************
		* Loads a core animation instance.
		*
		* This function loads a core animation instance from a file.
		*
		* @param strFilename The file to load the core animation instance from.
		*
		* @return One of the following values:
		*         \li a pointer to the core animation
		*         \li \b 0 if an error happened
		*****************************************************************************/
		public function loadCoreAnimation( filename:String, skeleton:CalCoreSkeleton ):void {

			//validate file extension
			trace("CalLoader::loadCoreAnimation " + filename);
	
			var ext:String =  filename.substring(filename.length-3, filename.length).toUpperCase();
			trace("CalLoader::loadCoreAnimation -- extension = " + ext );
			if( (filename.length >= 3) && (ext == CalConstant.ANIMATION_XMLFILE_EXTENSION ) ) {
				
				this.addEventListener(Event.COMPLETE, loadXmlCoreAnimation); //wait for XML file to completely download
				this.skeleton = skeleton;
				this.load(new URLRequest(filename));			
			}else{
				//binary cal3d files not yet supported
				trace("CalLoader: binary cal3d files (CAF) not yet supported");
			}
			return;
		}


		private var animationFilenameMap:HashMap = new HashMap();

		public function loadCoreAnimationById( filename:String, skeleton:CalCoreSkeleton, id:int ):void {

			//validate file extension
			trace("CalLoader::loadCoreAnimation " + filename);
	
			var ext:String =  filename.substring(filename.length-3, filename.length).toUpperCase();
			trace("CalLoader::loadCoreAnimation -- extension = " + ext );
			if( (filename.length >= 3) && (ext == CalConstant.ANIMATION_XMLFILE_EXTENSION ) ) {
				
				assetId = id;
				
				this.addEventListener(Event.COMPLETE, loadXmlCoreAnimation); //wait for XML file to completely download
				this.skeleton = skeleton;
				this.load(new URLRequest(filename));			
			}else{
				//binary cal3d files not yet supported
				trace("CalLoader: binary cal3d files (CAF) not yet supported");
			}
			return;

		
		}
		
		
	 	/*****************************************************************************
		* Loads a core mesh instance from a Xml file.
		*
		* This function loads a core mesh instance from a Xml file.
		*
		* @param strFilename The name of the file to load the core mesh instance from.
		*
		* @return One of the following values:
		*         \li a pointer to the core mesh
		*         \li \b 0 if an error happened
		*****************************************************************************/
		public function loadXmlCoreMesh( event:Event ):void {

			trace("loadXMLCoreMesh");
			//file loaded, now listen for file parsing completion
			this.removeEventListener(Event.COMPLETE, loadXmlCoreMesh);
			
			var loader:URLLoader = URLLoader(event.target);
			var XMLdata:XMLList = new XMLList(loader.data);
			
			//wrap file in root node so that we can parse it correctly
			var root:XML = <root> { XMLdata } </root>;

			//interpret file
			var submeshes:XMLList = root.descendants("SUBMESH");
			
			//trace("submeshes count: " + submeshes.length() );

			// get the number of submeshes
			var submeshCount:int = parseInt(XMLdata.@NUMSUBMESH);
			//trace("count " + submeshCount );

			// allocate a new core mesh instance
			var coreMesh:CalCoreMesh = new CalCoreMesh;

			// load all core submeshes
			for each(var submesh:XML in submeshes){

				// get the material thread id of the submesh
				var coreMaterialThreadId:int = parseInt(submesh.@MATERIAL);

				// get the number of vertices, faces, level-of-details and springs
				var vertexCount:int = parseInt(submesh.@NUMVERTICES);
				var faceCount:int = parseInt(submesh.@NUMFACES);
				var lodCount:int = parseInt(submesh.@NUMLODSTEPS);
				var springCount:int = parseInt(submesh.@NUMSPRINGS);
				var textureCoordinateCount:int = parseInt(submesh.@NUMTEXCOORDS);

				// allocate a new core submesh instance
				var coreSubmesh:CalCoreSubmesh = new CalCoreSubmesh(vertexCount, textureCoordinateCount, faceCount, springCount);

				// set the LOD step count
				coreSubmesh.setLodCount(lodCount);

				// set the core material id
				coreSubmesh.setCoreMaterialThreadId(coreMaterialThreadId);

				// load all vertices and their influences
				var vertices:XMLList = submesh.descendants("VERTEX");
				
				var vertexId:int = 0;
				for each(var v:XML in vertices){
					
					var vertex:Vertex = new Vertex();
					
					var pos:Array = String(v.child("POS")).split(" ");
					var norm:Array = String(v.child("NORM")).split(" ");
					
					vertex.position.x = parseFloat(pos[0]);
					vertex.position.y = parseFloat(pos[1]);
					vertex.position.z = parseFloat(pos[2]);
					
					vertex.normal.x = parseFloat(norm[0]);
					vertex.normal.y = parseFloat(norm[1]);
					vertex.normal.z = parseFloat(norm[2]);
					
					//setup texture coordinates
					var textureCoordinateId:int = 0;
					var textureCoordinates:XMLList = v.descendants("TEXCOORD");
					for each(var texCoord:XML in textureCoordinates){
						var tc:Array = String(texCoord.child("TEXCOORD")).split(" ");
						var textureCoordinate:TextureCoordinate = new TextureCoordinate();
						textureCoordinate.u = parseFloat(tc[0]);
						textureCoordinate.v = parseFloat(tc[1]);
						
						if (loadingMode == LOADER_INVERT_V_COORD) {
							textureCoordinate.v = 1.0 - textureCoordinate.v;
						}
						// set texture coordinate in the core submesh instance
						coreSubmesh.setTextureCoordinate(vertexId, textureCoordinateId, textureCoordinate);
						++textureCoordinateId;	
					}
				
					var collapseId:int;
					if( String(v.child("COLLAPSEID")).length > 0 ){
						collapseId = parseInt(v.child("COLLAPSEID"));
					}else collapseId = -1;
					
					var collapseCount:int;
					if( String(v.child("COLLAPSECOUNT")).length > 0 ){
						collapseCount = parseInt(v.child("COLLAPSECOUNT"));
					}else collapseCount = 0;
					
					vertex.collapseId = collapseId;
					vertex.faceCollapseCount =  collapseCount;
					//trace(vertex.collapseId + " " + vertex.faceCollapseCount);
					// load all influences of the vertex
					var influences:XMLList = v.descendants("INFLUENCE");
					var influenceId:int = 0;
					//trace("this vertex has: " + influences.length() + " influences");
					for each(var inf:XML in influences){
						//trace("Creating influencevg");
						var influence:Influence = new Influence(parseInt(inf.@ID), parseFloat(inf.valueOf()) );
						//trace("Influence: id: " + influence.boneId + " weight: " + influence.weight);
						vertex.vectorInfluence.push(influence);
						++influenceId;			
					}	
					
					// load the physical property of the vertex if there are springs in the core submesh
					if(springCount > 0) {
			
						var physicalProperty:PhysicalProperty = new PhysicalProperty();
						physicalProperty.weight = parseFloat( v.child("PHYSIQUE") );

						// set the physical property in the core submesh instance
						coreSubmesh.setPhysicalProperty(vertexId, physicalProperty);          
					}
					
					// set vertex in the core submesh instance
					coreSubmesh.setVertex(vertexId, vertex);
					++vertexId;		
				}
			
				/*
				// load all springs
				var springs:XMLList = submesh.descendants("SPRING");
				var springId:int = 0;
				for each(var s:XML in springs)
					var spring:Spring = new Spring();
		
					parseInt(s.@VERTEXID);
					
					Spring.vertexId[0] 
					Spring.vertexId[1] 
					spring.springCoefficient = parseFloat(s.@COEF);
					spring.idleLength = parseFloat(s.@LENGTH);
		
					// set spring in the core submesh instance
					coreSubmesh.setSpring(springId, spring);
					
				}
				*/
	
				// load all faces
				var faces:XMLList = submesh.descendants("FACE");
				var faceId:int;
				for each(var f:XML in faces){
					//trace("face xml: " + f.valueOf() + " " + f);
					var faceVertexIds:Array = String( f.@VERTEXID ).split(" ");
					var tmp:Array = new Array(3);
					// load data of the face
					tmp[0] = parseInt(faceVertexIds[0]);
					tmp[1] = parseInt(faceVertexIds[1]);
					tmp[2] = parseInt(faceVertexIds[2]);
				
					var face:Face = new Face(tmp);
					coreSubmesh.setFace(faceId, face);
					//trace("Creating Face -- " + faceId + " " + face.vertexId[0] + " " + face.vertexId[1] + " " + face.vertexId[2]);
					++faceId;
				}
		
				// add the core submesh to the core mesh instance
				coreMesh.addCoreSubmesh(coreSubmesh);
			}

			//if a name is specified, assign it
			if(assetName != null){ coreMesh.setName(assetName);
				trace("setting name as " + assetName);
			}
			this.dispatchEvent( new CalEvent( CalEvent.MESH_LOADED, coreMesh) );
		}

		
		
		static public function parseXmlCoreMesh( xmldat:String ):CalCoreMesh {

			trace("loadXMLCoreMesh");
			//file loaded, now listen for file parsing completion
			
			
			
			var XMLdata:XMLList = new XMLList(xmldat);
			
			//wrap file in root node so that we can parse it correctly
			var root:XML = <root> { XMLdata } </root>;

			//interpret file
			var submeshes:XMLList = root.descendants("SUBMESH");
			
			//trace("submeshes count: " + submeshes.length() );

			// get the number of submeshes
			var submeshCount:int = parseInt(XMLdata.@NUMSUBMESH);
			//trace("count " + submeshCount );

			// allocate a new core mesh instance
			var coreMesh:CalCoreMesh = new CalCoreMesh;

			// load all core submeshes
			for each(var submesh:XML in submeshes){

				// get the material thread id of the submesh
				var coreMaterialThreadId:int = parseInt(submesh.@MATERIAL);

				// get the number of vertices, faces, level-of-details and springs
				var vertexCount:int = parseInt(submesh.@NUMVERTICES);
				var faceCount:int = parseInt(submesh.@NUMFACES);
				var lodCount:int = parseInt(submesh.@NUMLODSTEPS);
				var springCount:int = parseInt(submesh.@NUMSPRINGS);
				var textureCoordinateCount:int = parseInt(submesh.@NUMTEXCOORDS);

				// allocate a new core submesh instance
				var coreSubmesh:CalCoreSubmesh = new CalCoreSubmesh(vertexCount, textureCoordinateCount, faceCount, springCount);

				// set the LOD step count
				coreSubmesh.setLodCount(lodCount);

				// set the core material id
				coreSubmesh.setCoreMaterialThreadId(coreMaterialThreadId);

				// load all vertices and their influences
				var vertices:XMLList = submesh.descendants("VERTEX");
				
				var vertexId:int = 0;
				for each(var v:XML in vertices){
					
					var vertex:Vertex = new Vertex();
					
					var pos:Array = String(v.child("POS")).split(" ");
					var norm:Array = String(v.child("NORM")).split(" ");
					
					vertex.position.x = parseFloat(pos[0]);
					vertex.position.y = parseFloat(pos[1]);
					vertex.position.z = parseFloat(pos[2]);
					
					vertex.normal.x = parseFloat(norm[0]);
					vertex.normal.y = parseFloat(norm[1]);
					vertex.normal.z = parseFloat(norm[2]);
					
					//setup texture coordinates
					var textureCoordinateId:int = 0;
					var textureCoordinates:XMLList = v.descendants("TEXCOORD");
					for each(var texCoord:XML in textureCoordinates){
						var tc:Array = String(texCoord.child("TEXCOORD")).split(" ");
						var textureCoordinate:TextureCoordinate = new TextureCoordinate();
						textureCoordinate.u = parseFloat(tc[0]);
						textureCoordinate.v = parseFloat(tc[1]);
						
						//if (loadingMode == LOADER_INVERT_V_COORD) {
						//	textureCoordinate.v = 1.0 - textureCoordinate.v;
						//}
						// set texture coordinate in the core submesh instance
						coreSubmesh.setTextureCoordinate(vertexId, textureCoordinateId, textureCoordinate);
						++textureCoordinateId;	
					}
				
					var collapseId:int;
					if( String(v.child("COLLAPSEID")).length > 0 ){
						collapseId = parseInt(v.child("COLLAPSEID"));
					}else collapseId = -1;
					
					var collapseCount:int;
					if( String(v.child("COLLAPSECOUNT")).length > 0 ){
						collapseCount = parseInt(v.child("COLLAPSECOUNT"));
					}else collapseCount = 0;
					
					vertex.collapseId = collapseId;
					vertex.faceCollapseCount =  collapseCount;
					//trace(vertex.collapseId + " " + vertex.faceCollapseCount);
					// load all influences of the vertex
					var influences:XMLList = v.descendants("INFLUENCE");
					var influenceId:int = 0;
					//trace("this vertex has: " + influences.length() + " influences");
					for each(var inf:XML in influences){
						//trace("Creating influencevg");
						var influence:Influence = new Influence(parseInt(inf.@ID), parseFloat(inf.valueOf()) );
						//trace("Influence: id: " + influence.boneId + " weight: " + influence.weight);
						vertex.vectorInfluence.push(influence);
						++influenceId;			
					}	
					
					// load the physical property of the vertex if there are springs in the core submesh
					if(springCount > 0) {
			
						var physicalProperty:PhysicalProperty = new PhysicalProperty();
						physicalProperty.weight = parseFloat( v.child("PHYSIQUE") );

						// set the physical property in the core submesh instance
						coreSubmesh.setPhysicalProperty(vertexId, physicalProperty);          
					}
					
					// set vertex in the core submesh instance
					coreSubmesh.setVertex(vertexId, vertex);
					++vertexId;		
				}
			
				/*
				// load all springs
				var springs:XMLList = submesh.descendants("SPRING");
				var springId:int = 0;
				for each(var s:XML in springs)
					var spring:Spring = new Spring();
		
					parseInt(s.@VERTEXID);
					
					Spring.vertexId[0] 
					Spring.vertexId[1] 
					spring.springCoefficient = parseFloat(s.@COEF);
					spring.idleLength = parseFloat(s.@LENGTH);
		
					// set spring in the core submesh instance
					coreSubmesh.setSpring(springId, spring);
					
				}
				*/
	
				// load all faces
				var faces:XMLList = submesh.descendants("FACE");
				var faceId:int;
				for each(var f:XML in faces){
					//trace("face xml: " + f.valueOf() + " " + f);
					var faceVertexIds:Array = String( f.@VERTEXID ).split(" ");
					var tmp:Array = new Array(3);
					// load data of the face
					tmp[0] = parseInt(faceVertexIds[0]);
					tmp[1] = parseInt(faceVertexIds[1]);
					tmp[2] = parseInt(faceVertexIds[2]);
				
					var face:Face = new Face(tmp);
					coreSubmesh.setFace(faceId, face);
					//trace("Creating Face -- " + faceId + " " + face.vertexId[0] + " " + face.vertexId[1] + " " + face.vertexId[2]);
					++faceId;
				}
		
				// add the core submesh to the core mesh instance
				coreMesh.addCoreSubmesh(coreSubmesh);
			}

			//if a name is specified, assign it
			//if(assetName != null){ coreMesh.setName(assetName);
			//	trace("setting name as " + assetName);
			//}
			//this.dispatchEvent( new CalEvent( CalEvent.MESH_LOADED, coreMesh) );
			
			return coreMesh;
		}		
		


		/*****************************************************************************
		* Loads a core skeleton instance from a XML file.
		*
		* This function loads a core skeleton instance from a XML file.
		*
		* @param strFilename The name of the file to load the core skeleton instance
		*                    from.
		*
		* @return One of the following values:
		*         \li a pointer to the core skeleton
		*         \li \b 0 if an error happened
		*****************************************************************************/
		public function loadXmlCoreSkeleton( event:Event ):void {
			
			trace("loading XML skeleton");
			
			//file loaded, now listen for file parsing completion
			this.removeEventListener(Event.COMPLETE, loadXmlCoreSkeleton);
			
			var loader:URLLoader = URLLoader(event.target);
			var XMLdata:XMLList = new XMLList(loader.data);
			
			//wrap file in root node so that we can parse it correctly
			var root:XML = <root> { XMLdata } </root>;
			
			//interpret file
    		var skeleton:XMLList = root.descendants("SKELETON");
    		var allBones:XMLList = root.descendants("BONE");

			//file format error
			if(skeleton.length() == 0){
				trace("CalLoader ERROR (No Skeleton declared) - INVALID_FILE_FORMAT");
				//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
				return;
			}
			
			if(allBones.length() == 0){
				trace("CalLoader ERROR (No Bones declared) - INVALID_FILE_FORMAT");
				//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
				return;
			}

			// allocate a new CoreSkeleton instance
			var coreSkeleton:CalCoreSkeleton = new CalCoreSkeleton();
	
			for each(var bone:XML in allBones){
				
				var name:String = bone.@NAME;
				var id:int = parseInt(bone.@ID);
				var t:Array = String(bone.child("TRANSLATION")).split(" ");
				var r:Array = String(bone.child("ROTATION")).split(" ");
				var lt:Array = String(bone.child("LOCALTRANSLATION")).split(" ");
				var lr:Array = String(bone.child("LOCALROTATION")).split(" ");
				var parentId:int = parseInt( bone.child("PARENTID") );
				
				var translation:CalVector = new CalVector(parseFloat(t[0]), parseFloat(t[1]), parseFloat(t[2]));
				var rotation:CalQuaternion = new CalQuaternion(parseFloat(r[0]), parseFloat(r[1]), parseFloat(r[2]), parseFloat(r[3]));
				var localTranslation:CalVector = new CalVector(parseFloat(lt[0]), parseFloat(lt[1]), parseFloat(lt[2]));
				var localRotation:CalQuaternion = new CalQuaternion(parseFloat(lr[0]), parseFloat(lr[1]), parseFloat(lr[2]), parseFloat(lr[3]));
				
				// only root bone necessary
				if (parentId == -1) {
					
					// Root bone must have quaternion rotated
					var x_axis_90:CalQuaternion = new CalQuaternion(0.7071067811, 0.0 ,0.0 , 0.7071067811);
					rotation.multiplyByQuaternion(x_axis_90);
					// Root bone must have translation rotated also
					translation.multiplyByQuaternion(x_axis_90);
				}
				
				//setup CoreBone
				var coreBone:CalCoreBone = new CalCoreBone(name);
				coreBone.parentId = parentId;
				coreBone.translation = translation;
				coreBone.rotation = rotation;
				coreBone.translationBoneSpace = localTranslation;
				coreBone.rotationBoneSpace =  localRotation;
				/*
				trace("** Loading CoreBone **");
				trace(coreBone.name);
				trace("translation: \t\t " + coreBone.translation);
				trace("translationBoneSpace: \t\t " + coreBone.translation);
				trace("rotation: \t\t" + rotation);
				trace("rotationBoneSpace: \t\t" + coreBone.rotationBoneSpace);
				trace("***********************");
				*/
				//add all childID bones
				var children:XMLList = bone.descendants("CHILDID");
				
				for each(var childId:XML in children){
					coreBone.addChildId(parseInt( childId.valueOf() ) );
				}
				
				// set the core skeleton of the core bone instance
				coreBone.coreSkeleton = coreSkeleton;

				// add the core bone to the core skeleton instance
				coreSkeleton.addCoreBone(coreBone);
			}
		
			coreSkeleton.calculateState();
			
			//CoreSkeleton is completely loaded, dispatch completion event
			this.dispatchEvent( new CalEvent( CalEvent.SKELETON_LOADED, coreSkeleton) );
		}
		
		static public function parseXmlCoreSkeleton( xmldata:String ):CalCoreSkeleton {
			
			trace("loading XML skeleton");
			
			//file loaded, now listen for file parsing completion
			//this.removeEventListener(Event.COMPLETE, loadXmlCoreSkeleton);
			
			
			var XMLdata:XMLList = new XMLList(xmldata);
			
			//wrap file in root node so that we can parse it correctly
			var root:XML = <root> { XMLdata } </root>;
			
			//interpret file
    		var skeleton:XMLList = root.descendants("SKELETON");
    		var allBones:XMLList = root.descendants("BONE");

			//file format error
			if(skeleton.length() == 0){
				trace("CalLoader ERROR (No Skeleton declared) - INVALID_FILE_FORMAT");
				//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
				return null;
			}
			
			if(allBones.length() == 0){
				trace("CalLoader ERROR (No Bones declared) - INVALID_FILE_FORMAT");
				//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
				return null;
			}

			// allocate a new CoreSkeleton instance
			var coreSkeleton:CalCoreSkeleton = new CalCoreSkeleton();
	
			for each(var bone:XML in allBones){
				
				var name:String = bone.@NAME;
				var id:int = parseInt(bone.@ID);
				var t:Array = String(bone.child("TRANSLATION")).split(" ");
				var r:Array = String(bone.child("ROTATION")).split(" ");
				var lt:Array = String(bone.child("LOCALTRANSLATION")).split(" ");
				var lr:Array = String(bone.child("LOCALROTATION")).split(" ");
				var parentId:int = parseInt( bone.child("PARENTID") );
				
				var translation:CalVector = new CalVector(parseFloat(t[0]), parseFloat(t[1]), parseFloat(t[2]));
				var rotation:CalQuaternion = new CalQuaternion(parseFloat(r[0]), parseFloat(r[1]), parseFloat(r[2]), parseFloat(r[3]));
				var localTranslation:CalVector = new CalVector(parseFloat(lt[0]), parseFloat(lt[1]), parseFloat(lt[2]));
				var localRotation:CalQuaternion = new CalQuaternion(parseFloat(lr[0]), parseFloat(lr[1]), parseFloat(lr[2]), parseFloat(lr[3]));
				
				// only root bone necessary
				if (parentId == -1) {
					
					// Root bone must have quaternion rotated
					var x_axis_90:CalQuaternion = new CalQuaternion(0.7071067811, 0.0 ,0.0 , 0.7071067811);
					rotation.multiplyByQuaternion(x_axis_90);
					// Root bone must have translation rotated also
					translation.multiplyByQuaternion(x_axis_90);
				}
				
				//setup CoreBone
				var coreBone:CalCoreBone = new CalCoreBone(name);
				coreBone.parentId = parentId;
				coreBone.translation = translation;
				coreBone.rotation = rotation;
				coreBone.translationBoneSpace = localTranslation;
				coreBone.rotationBoneSpace =  localRotation;
				/*
				trace("** Loading CoreBone **");
				trace(coreBone.name);
				trace("translation: \t\t " + coreBone.translation);
				trace("translationBoneSpace: \t\t " + coreBone.translation);
				trace("rotation: \t\t" + rotation);
				trace("rotationBoneSpace: \t\t" + coreBone.rotationBoneSpace);
				trace("***********************");
				*/
				//add all childID bones
				var children:XMLList = bone.descendants("CHILDID");
				
				for each(var childId:XML in children){
					coreBone.addChildId(parseInt( childId.valueOf() ) );
				}
				
				// set the core skeleton of the core bone instance
				coreBone.coreSkeleton = coreSkeleton;

				// add the core bone to the core skeleton instance
				coreSkeleton.addCoreBone(coreBone);
			}
		
			coreSkeleton.calculateState();
			
			//CoreSkeleton is completely loaded, dispatch completion event
			//this.dispatchEvent( new CalEvent( CalEvent.SKELETON_LOADED, coreSkeleton) );
			
			return coreSkeleton;
			
		}		
		
		/*****************************************************************************
		* Loads a core animation instance from a XML file.
		*
		* This function loads a core animation instance from a XML file.
		*
		* @param strFilename The name of the file to load the core animation instance
		*                    from.
		*
		* @return One of the following values:
		*         \li a pointer to the core animation
		*         \li \b 0 if an error happened
		*****************************************************************************/

		public function loadXmlCoreAnimation( event:Event ):void {//CalCoreAnimation 
			//this.l
			//event.
			trace("loadXMLCoreAnimation");
			//file loaded, now listen for file parsing completion
			this.removeEventListener(Event.COMPLETE, loadXmlCoreAnimation);
			
			var loader:URLLoader = URLLoader(event.target);
			var XMLdata:XMLList = new XMLList(loader.data);
			
			//wrap file in root node so that we can parse it correctly
			var root:XML = <root> { XMLdata } </root>;

			//interpret file
			var animation:XMLList = root.child("ANIMATION");
    		var tracks:XMLList = root.descendants("TRACK");

			//file format error
			if(animation.length() == 0){
				trace("CalLoader ERROR (No Animation declared) - INVALID_FILE_FORMAT");
				//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
				return;
			}
			
			var coreAnimation:CalCoreAnimation = new CalCoreAnimation();		
	
			var trackCount:int = parseInt( animation.@NUMTRACKS );
			var duration:Number = parseFloat( animation.@DURATION );
	
			// check for a valid duration
			if(duration <= 0.0) {
				//CalError::setLastError(CalError::INVALID_ANIMATION_DURATION, __FILE__, __LINE__, strFilename);
				trace("CalLoader ERROR (Duration must be > 0.0) - INVALID_FILE_FORMAT");
				return;
			}

			// set the duration in the core animation instance
			coreAnimation.duration = duration;

			// load all core bones
			for each(var track:XML in tracks) {
				
				// create the core track instance
				var coreTrack:CalCoreTrack = new CalCoreTrack();

				var coreBoneId:int = parseInt( track.@BONEID );

				// link the core track to the appropriate core bone instance
				coreTrack.setCoreBoneId(coreBoneId);

				// read the number of keyframes
				var keyframes:XMLList = track.descendants("KEYFRAME");
				var keyframeCount:int = parseInt(track.@NUMKEYFRAMES);

				if(keyframeCount <= 0) {
					//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
					trace("CalLoader ERROR (KeyframeCount must be > 0) - INVALID_FILE_FORMAT");
					return;
				}
				
				for each(var keyframe:XML in keyframes){

					var time:Number = parseFloat(keyframe.@TIME);

					var t:Array = String(keyframe.child("TRANSLATION")).split(" ");
					var r:Array = String(keyframe.child("ROTATION")).split(" ");

					var translation:CalVector = new CalVector(parseFloat(t[0]), parseFloat(t[1]), parseFloat(t[2]));
					var rotation:CalQuaternion = new CalQuaternion(parseFloat(r[0]), parseFloat(r[1]), parseFloat(r[2]), parseFloat(r[3]));

					// allocate a new core keyframe instance
					var coreKeyframe:CalCoreKeyframe = new CalCoreKeyframe();
		
					// set all attributes of the keyframe
					coreKeyframe.setTime(time);
					coreKeyframe.setTranslation(translation);
					coreKeyframe.setRotation(rotation);
					
					if (loadingMode == LOADER_ROTATE_X_AXIS) {
						// Check for anim rotation
						if (this.skeleton.getCoreBone(coreBoneId).parentId == -1) {  // root bone
							// rotate root bone quaternion
							var rot:CalQuaternion = coreKeyframe.getRotation().clone();
							var x_axis_90:CalQuaternion = new CalQuaternion(0.7071067811, 0.0, 0.0, 0.7071067811);
							rot.multiplyByQuaternion( x_axis_90 );
							coreKeyframe.setRotation(rot);
							// rotate root bone displacement
							var trans:CalVector = coreKeyframe.getTranslation().clone();
							trans.multiplyByQuaternion( x_axis_90 );
							coreKeyframe.setTranslation(trans);
						}
					}    

				// add the core keyframe to the core track instance
				coreTrack.addCoreKeyframe(coreKeyframe);
		}

		coreAnimation.addCoreTrack(coreTrack);	  
	}
	
	//check to see if an id is manually specified
	//this.animationFilenameMap.containsKey(filename
	//CoreAnimation is completely loaded, dispatch completion event
	this.dispatchEvent( new CalEvent( CalEvent.ANIMATION_LOADED, coreAnimation, assetId) );
	//return coreAnimation;
	}

	
	
		static public function parseXmlCoreAnimation( xmldat:String, skel:CalCoreSkeleton ):CalCoreAnimation {
			//this.l
			//event.
			trace("loadXMLCoreAnimation");
			//file loaded, now listen for file parsing completion
			//this.removeEventListener(Event.COMPLETE, loadXmlCoreAnimation);
			
			
			var XMLdata:XMLList = new XMLList(xmldat);
			
			//wrap file in root node so that we can parse it correctly
			var root:XML = <root> { XMLdata } </root>;

			//interpret file
			var animation:XMLList = root.child("ANIMATION");
    		var tracks:XMLList = root.descendants("TRACK");

			//file format error
			if(animation.length() == 0){
				trace("CalLoader ERROR (No Animation declared) - INVALID_FILE_FORMAT");
				//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
				return null;
			}
			
			var coreAnimation:CalCoreAnimation = new CalCoreAnimation();		
	
			var trackCount:int = parseInt( animation.@NUMTRACKS );
			var duration:Number = parseFloat( animation.@DURATION );
	
			// check for a valid duration
			if(duration <= 0.0) {
				//CalError::setLastError(CalError::INVALID_ANIMATION_DURATION, __FILE__, __LINE__, strFilename);
				trace("CalLoader ERROR (Duration must be > 0.0) - INVALID_FILE_FORMAT");
				return null;
			}

			// set the duration in the core animation instance
			coreAnimation.duration = duration;

			// load all core bones
			for each(var track:XML in tracks) {
				
				// create the core track instance
				var coreTrack:CalCoreTrack = new CalCoreTrack();

				var coreBoneId:int = parseInt( track.@BONEID );

				// link the core track to the appropriate core bone instance
				coreTrack.setCoreBoneId(coreBoneId);

				// read the number of keyframes
				var keyframes:XMLList = track.descendants("KEYFRAME");
				var keyframeCount:int = parseInt(track.@NUMKEYFRAMES);

				if(keyframeCount <= 0) {
					//CalError::setLastError(CalError::INVALID_FILE_FORMAT, __FILE__, __LINE__, strFilename);
					trace("CalLoader ERROR (KeyframeCount must be > 0) - INVALID_FILE_FORMAT");
					return null;
				}
				
				for each(var keyframe:XML in keyframes){

					var time:Number = parseFloat(keyframe.@TIME);

					var t:Array = String(keyframe.child("TRANSLATION")).split(" ");
					var r:Array = String(keyframe.child("ROTATION")).split(" ");

					var translation:CalVector = new CalVector(parseFloat(t[0]), parseFloat(t[1]), parseFloat(t[2]));
					var rotation:CalQuaternion = new CalQuaternion(parseFloat(r[0]), parseFloat(r[1]), parseFloat(r[2]), parseFloat(r[3]));

					// allocate a new core keyframe instance
					var coreKeyframe:CalCoreKeyframe = new CalCoreKeyframe();
		
					// set all attributes of the keyframe
					coreKeyframe.setTime(time);
					coreKeyframe.setTranslation(translation);
					coreKeyframe.setRotation(rotation);
					
					//if (loadingMode == LOADER_ROTATE_X_AXIS) {
						// Check for anim rotation
						if (skel.getCoreBone(coreBoneId).parentId == -1) {  // root bone
							// rotate root bone quaternion
							var rot:CalQuaternion = coreKeyframe.getRotation().clone();
							var x_axis_90:CalQuaternion = new CalQuaternion(0.7071067811, 0.0, 0.0, 0.7071067811);
							rot.multiplyByQuaternion( x_axis_90 );
							coreKeyframe.setRotation(rot);
							// rotate root bone displacement
							var trans:CalVector = coreKeyframe.getTranslation().clone();
							trans.multiplyByQuaternion( x_axis_90 );
							coreKeyframe.setTranslation(trans);
						}
					//}    

				// add the core keyframe to the core track instance
				coreTrack.addCoreKeyframe(coreKeyframe);
		}

		coreAnimation.addCoreTrack(coreTrack);	  
	}
	
		//check to see if an id is manually specified
		//this.animationFilenameMap.containsKey(filename
		//CoreAnimation is completely loaded, dispatch completion event
		//this.dispatchEvent( new CalEvent( CalEvent.ANIMATION_LOADED, coreAnimation, assetId) );
		return coreAnimation;
	}	
	
		

	}

class c_App extends Object{
	public function m_App_new():c_App{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<152>";
		if((bb_app__app)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<152>";
			error("App has already been created");
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<153>";
		bb_app__app=this;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<154>";
		bb_app__delegate=(new c_GameDelegate).m_GameDelegate_new();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<155>";
		bb_app__game.SetDelegate(bb_app__delegate);
		popErr();
		return this;
	}
	public function p_OnResize():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_OnCreate():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_OnSuspend():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_OnResume():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_OnUpdate():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_OnLoading():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_OnRender():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_OnClose():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<177>";
		bb_app_EndApp();
		popErr();
		return 0;
	}
	public function p_OnBack():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<181>";
		this.p_OnClose();
		popErr();
		return 0;
	}
}
class c_Game extends c_App{
	public function m_Game_new():c_Game{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<13>";
		super.m_App_new();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<13>";
		popErr();
		return this;
	}
	public override function p_OnCreate():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<27>";
		bb_flash11_SetRender(0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<28>";
		bb_app_SetUpdateRate(30);
		popErr();
		return 0;
	}
	internal var m_init_gl:Boolean=false;
	internal var m_dt:c_DeltaTimer=null;
	internal var m_cam:c_TCamera=null;
	internal var m_light:c_TLight=null;
	internal var m_TestModel:c_Cal3dB3d=null;
	internal var m_txt:c_TText=null;
	public function p_Init():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<34>";
		if(m_init_gl==true){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<34>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<36>";
		m_dt=(new c_DeltaTimer).m_DeltaTimer_new(30.0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<37>";
		if(!((c_TPixmap.m_PreLoadPixmap(["mojo_font.png"]))!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<38>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<40>";
		m_cam=bb_functions_CreateCamera(null);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<41>";
		m_cam.p_CameraClsColor(0.0,0.0,80.0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<42>";
		m_cam.p_PositionEntity(0.0,4.0,-10.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<43>";
		m_light=bb_functions_CreateLight(1,null);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<44>";
		m_light.p_PositionEntity(0.0,3.0,-3.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<46>";
		m_TestModel=(new c_Cal3dB3d).m_Cal3dB3d_new();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<47>";
		m_TestModel.p_SetSkeleton("monkey://data/paladin/test.xsf");
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<48>";
		m_TestModel.p_AddMesh("monkey://data/paladin/testp.xmf");
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<49>";
		m_TestModel.p_AddAnim("monkey://data/paladin/run.xaf");
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<53>";
		m_TestModel.p_Build();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<54>";
		if(dbg_object(m_TestModel).m_CModel.getMixer().blendCycle(0,1.0,0.0)){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<55>";
			print("Execute Run!");
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<59>";
		m_txt=c_TText.m_CreateText2D(null,"","",96,9,0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<60>";
		print("main: init done");
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<61>";
		m_init_gl=true;
		popErr();
		return 0;
	}
	internal var m_touchBegin:int=0;
	internal var m_oldTouchX:int=0;
	internal var m_oldTouchY:int=0;
	internal var m_lr:Number=.0;
	internal var m_ud:Number=.0;
	public override function p_OnUpdate():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<67>";
		if(((bb_input_KeyHit(432))!=0) || ((bb_input_KeyHit(27))!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<67>";
			error("");
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<68>";
		if(m_init_gl==true){
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<71>";
		if(m_init_gl==false){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<72>";
			this.p_Init();
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<73>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<75>";
		m_dt.p_UpdateDelta();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<77>";
		var t_cr:Number=(bb_input_KeyDown(37)-bb_input_KeyDown(39));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<78>";
		var t_cu:Number=(bb_input_KeyDown(40)-bb_input_KeyDown(38));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<80>";
		var t_camin:Number=(bb_input_KeyDown(87)-bb_input_KeyDown(83));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<81>";
		var t_camup:Number=(bb_input_KeyDown(68)-bb_input_KeyDown(65));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<83>";
		var t_turnzx:Number=(bb_input_KeyDown(90)-bb_input_KeyDown(88));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<85>";
		if(((bb_input_TouchDown(0))!=0) && !((bb_input_TouchDown(1))!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<86>";
			if(!((m_touchBegin)!=0)){
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<87>";
				m_oldTouchX=((bb_input_TouchX(0))|0);
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<88>";
				m_oldTouchY=((bb_input_TouchY(0))|0);
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<89>";
				m_touchBegin=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<91>";
			m_lr=(bb_input_TouchX(0)-(m_oldTouchX))*0.5;
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<92>";
			m_ud=(-bb_input_TouchY(0)+(m_oldTouchY))*0.5;
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<93>";
			m_oldTouchX=((bb_input_TouchX(0))|0);
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<94>";
			m_oldTouchY=((bb_input_TouchY(0))|0);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<95>";
			if((bb_input_TouchDown(1))!=0){
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<96>";
				if(!((m_touchBegin)!=0)){
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<97>";
					m_oldTouchX=((bb_input_TouchX(0))|0);
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<98>";
					m_oldTouchY=((bb_input_TouchY(0))|0);
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<99>";
					m_touchBegin=1;
				}
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<101>";
				t_camup=(-bb_input_TouchX(0)+(m_oldTouchX))*0.1;
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<102>";
				t_camin=(-bb_input_TouchY(0)+(m_oldTouchY))*0.1;
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<103>";
				m_oldTouchX=((bb_input_TouchX(0))|0);
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<104>";
				m_oldTouchY=((bb_input_TouchY(0))|0);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<106>";
				m_touchBegin=0;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<109>";
		m_cam.p_MoveEntity(t_camup,0.0,t_camin);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<110>";
		m_cam.p_TurnEntity(t_cu,t_cr,0.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<112>";
		m_txt.p_SetText("Cam: "+String(t_camup)+" "+String(t_camin)+" "+String(t_cu)+" "+String(t_cr)+" delta: "+String(dbg_object(m_dt).m_delta),0.0,0.0,0.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<113>";
		m_txt.p_HideEntity();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<114>";
		m_txt.p_Draw(0.0,0.0,false);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<115>";
		m_TestModel.p_Update5(dbg_object(m_dt).m_delta/30.0);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<116>";
		bb_functions_UpdateWorld(1.0);
		popErr();
		return 0;
	}
	public override function p_OnRender():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<121>";
		bb_functions_RenderWorld();
		popErr();
		return 0;
	}
}
var bb_app__app:c_App;
class c_GameDelegate extends BBGameDelegate{
	public function m_GameDelegate_new():c_GameDelegate{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<65>";
		popErr();
		return this;
	}
	internal var m__graphics:gxtkGraphics=null;
	internal var m__audio:gxtkAudio=null;
	internal var m__input:c_InputDevice=null;
	public override function StartGame():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<75>";
		m__graphics=(new gxtkGraphics);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<76>";
		bb_graphics_SetGraphicsDevice(m__graphics);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<77>";
		bb_graphics_SetFont(null,32);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<79>";
		m__audio=(new gxtkAudio);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<80>";
		bb_audio_SetAudioDevice(m__audio);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<82>";
		m__input=(new c_InputDevice).m_InputDevice_new();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<83>";
		bb_input_SetInputDevice(m__input);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<85>";
		bb_app_ValidateDeviceWindow(false);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<87>";
		bb_app_EnumDisplayModes();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<89>";
		bb_app__app.p_OnCreate();
		popErr();
	}
	public override function SuspendGame():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<93>";
		bb_app__app.p_OnSuspend();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<94>";
		m__audio.Suspend();
		popErr();
	}
	public override function ResumeGame():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<98>";
		m__audio.Resume();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<99>";
		bb_app__app.p_OnResume();
		popErr();
	}
	public override function UpdateGame():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<103>";
		bb_app_ValidateDeviceWindow(true);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<104>";
		m__input.p_BeginUpdate();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<105>";
		bb_app__app.p_OnUpdate();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<106>";
		m__input.p_EndUpdate();
		popErr();
	}
	public override function RenderGame():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<110>";
		bb_app_ValidateDeviceWindow(true);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<111>";
		var t_mode:int=m__graphics.BeginRender();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<112>";
		if((t_mode)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<112>";
			bb_graphics_BeginRender();
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<113>";
		if(t_mode==2){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<113>";
			bb_app__app.p_OnLoading();
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<113>";
			bb_app__app.p_OnRender();
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<114>";
		if((t_mode)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<114>";
			bb_graphics_EndRender();
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<115>";
		m__graphics.EndRender();
		popErr();
	}
	public override function KeyEvent(t_event:int,t_data:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<119>";
		m__input.p_KeyEvent(t_event,t_data);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<120>";
		if(t_event!=1){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<121>";
		var t_1:int=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<122>";
		if(t_1==432){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<123>";
			bb_app__app.p_OnClose();
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<124>";
			if(t_1==416){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<125>";
				bb_app__app.p_OnBack();
			}
		}
		popErr();
	}
	public override function MouseEvent(t_event:int,t_data:int,t_x:Number,t_y:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<130>";
		m__input.p_MouseEvent(t_event,t_data,t_x,t_y);
		popErr();
	}
	public override function TouchEvent(t_event:int,t_data:int,t_x:Number,t_y:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<134>";
		m__input.p_TouchEvent(t_event,t_data,t_x,t_y);
		popErr();
	}
	public override function MotionEvent(t_event:int,t_data:int,t_x:Number,t_y:Number,t_z:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<138>";
		m__input.p_MotionEvent(t_event,t_data,t_x,t_y,t_z);
		popErr();
	}
	public override function DiscardGraphics():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<142>";
		m__graphics.DiscardGraphics();
		popErr();
	}
}
var bb_app__delegate:c_GameDelegate;
var bb_app__game:BBGame;
internal function bbMain():int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<8>";
	(new c_Game).m_Game_new();
	popErr();
	return 0;
}
var bb_graphics_device:gxtkGraphics;
internal function bb_graphics_SetGraphicsDevice(t_dev:gxtkGraphics):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<63>";
	bb_graphics_device=t_dev;
	popErr();
	return 0;
}
class c_Image extends Object{
	internal static var m_DefaultFlags:int;
	public function m_Image_new():c_Image{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<70>";
		popErr();
		return this;
	}
	internal var m_surface:gxtkSurface=null;
	internal var m_width:int=0;
	internal var m_height:int=0;
	internal var m_frames:Array=[];
	internal var m_flags:int=0;
	internal var m_tx:Number=.0;
	internal var m_ty:Number=.0;
	public function p_SetHandle(t_tx:Number,t_ty:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<114>";
		dbg_object(this).m_tx=t_tx;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<115>";
		dbg_object(this).m_ty=t_ty;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<116>";
		dbg_object(this).m_flags=dbg_object(this).m_flags&-2;
		popErr();
		return 0;
	}
	public function p_ApplyFlags(t_iflags:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<192>";
		m_flags=t_iflags;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<194>";
		if((m_flags&2)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<195>";
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<195>";
			var t_:Array=m_frames;
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<195>";
			var t_2:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<195>";
			while(t_2<t_.length){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<195>";
				var t_f:c_Frame=dbg_array(t_,t_2)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<195>";
				t_2=t_2+1;
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<196>";
				dbg_object(t_f).m_x+=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<198>";
			m_width-=2;
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<201>";
		if((m_flags&4)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<202>";
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<202>";
			var t_3:Array=m_frames;
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<202>";
			var t_4:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<202>";
			while(t_4<t_3.length){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<202>";
				var t_f2:c_Frame=dbg_array(t_3,t_4)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<202>";
				t_4=t_4+1;
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<203>";
				dbg_object(t_f2).m_y+=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<205>";
			m_height-=2;
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<208>";
		if((m_flags&1)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<209>";
			this.p_SetHandle((m_width)/2.0,(m_height)/2.0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<212>";
		if(m_frames.length==1 && dbg_object(dbg_array(m_frames,0)[dbg_index]).m_x==0 && dbg_object(dbg_array(m_frames,0)[dbg_index]).m_y==0 && m_width==m_surface.Width() && m_height==m_surface.Height()){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<213>";
			m_flags|=65536;
		}
		popErr();
		return 0;
	}
	public function p_Init2(t_surf:gxtkSurface,t_nframes:int,t_iflags:int):c_Image{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<150>";
		m_surface=t_surf;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<152>";
		m_width=((m_surface.Width()/t_nframes)|0);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<153>";
		m_height=m_surface.Height();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<155>";
		m_frames=new_object_array(t_nframes);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<156>";
		for(var t_i:int=0;t_i<t_nframes;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<157>";
			dbg_array(m_frames,t_i)[dbg_index]=(new c_Frame).m_Frame_new(t_i*m_width,0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<160>";
		this.p_ApplyFlags(t_iflags);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<161>";
		popErr();
		return this;
	}
	internal var m_source:c_Image=null;
	public function p_Init3(t_surf:gxtkSurface,t_x:int,t_y:int,t_iwidth:int,t_iheight:int,t_nframes:int,t_iflags:int,t_src:c_Image,t_srcx:int,t_srcy:int,t_srcw:int,t_srch:int):c_Image{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<165>";
		m_surface=t_surf;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<166>";
		m_source=t_src;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<168>";
		m_width=t_iwidth;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<169>";
		m_height=t_iheight;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<171>";
		m_frames=new_object_array(t_nframes);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<173>";
		var t_ix:int=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<173>";
		var t_iy:int=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<175>";
		for(var t_i:int=0;t_i<t_nframes;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<176>";
			if(t_ix+m_width>t_srcw){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<177>";
				t_ix=0;
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<178>";
				t_iy+=m_height;
			}
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<180>";
			if(t_ix+m_width>t_srcw || t_iy+m_height>t_srch){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<181>";
				error("Image frame outside surface");
			}
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<183>";
			dbg_array(m_frames,t_i)[dbg_index]=(new c_Frame).m_Frame_new(t_ix+t_srcx,t_iy+t_srcy);
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<184>";
			t_ix+=m_width;
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<187>";
		this.p_ApplyFlags(t_iflags);
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<188>";
		popErr();
		return this;
	}
	public function p_Width():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<81>";
		popErr();
		return m_width;
	}
}
class c_GraphicsContext extends Object{
	public function m_GraphicsContext_new():c_GraphicsContext{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<29>";
		popErr();
		return this;
	}
	internal var m_defaultFont:c_Image=null;
	internal var m_font:c_Image=null;
	internal var m_firstChar:int=0;
	internal var m_matrixSp:int=0;
	internal var m_ix:Number=1.0;
	internal var m_iy:Number=.0;
	internal var m_jx:Number=.0;
	internal var m_jy:Number=1.0;
	internal var m_tx:Number=.0;
	internal var m_ty:Number=.0;
	internal var m_tformed:int=0;
	internal var m_matDirty:int=0;
	internal var m_color_r:Number=.0;
	internal var m_color_g:Number=.0;
	internal var m_color_b:Number=.0;
	internal var m_alpha:Number=.0;
	internal var m_blend:int=0;
	internal var m_scissor_x:Number=.0;
	internal var m_scissor_y:Number=.0;
	internal var m_scissor_width:Number=.0;
	internal var m_scissor_height:Number=.0;
}
var bb_graphics_context:c_GraphicsContext;
internal function bb_data_FixDataPath(t_path:String):String{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/data.monkey<7>";
	var t_i:int=t_path.indexOf(":/",0);
	_errInfo="C:/MonkeyXPro77f/modules/mojo/data.monkey<8>";
	if(t_i!=-1 && t_path.indexOf("/",0)==t_i+1){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/data.monkey<8>";
		popErr();
		return t_path;
	}
	_errInfo="C:/MonkeyXPro77f/modules/mojo/data.monkey<9>";
	if(string_startswith(t_path,"./") || string_startswith(t_path,"/")){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/data.monkey<9>";
		popErr();
		return t_path;
	}
	_errInfo="C:/MonkeyXPro77f/modules/mojo/data.monkey<10>";
	var t_:String="monkey://data/"+t_path;
	popErr();
	return t_;
}
class c_Frame extends Object{
	internal var m_x:int=0;
	internal var m_y:int=0;
	public function m_Frame_new(t_x:int,t_y:int):c_Frame{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<23>";
		dbg_object(this).m_x=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<24>";
		dbg_object(this).m_y=t_y;
		popErr();
		return this;
	}
	public function m_Frame_new2():c_Frame{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<18>";
		popErr();
		return this;
	}
}
internal function bb_graphics_LoadImage(t_path:String,t_frameCount:int,t_flags:int):c_Image{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<244>";
	var t_surf:gxtkSurface=bb_graphics_device.LoadSurface(bb_data_FixDataPath(t_path));
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<245>";
	if((t_surf)!=null){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<245>";
		var t_:c_Image=((new c_Image).m_Image_new()).p_Init2(t_surf,t_frameCount,t_flags);
		popErr();
		return t_;
	}
	popErr();
	return null;
}
internal function bb_graphics_LoadImage2(t_path:String,t_frameWidth:int,t_frameHeight:int,t_frameCount:int,t_flags:int):c_Image{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<249>";
	var t_surf:gxtkSurface=bb_graphics_device.LoadSurface(bb_data_FixDataPath(t_path));
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<250>";
	if((t_surf)!=null){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<250>";
		var t_:c_Image=((new c_Image).m_Image_new()).p_Init3(t_surf,0,0,t_frameWidth,t_frameHeight,t_frameCount,t_flags,null,0,0,t_surf.Width(),t_surf.Height());
		popErr();
		return t_;
	}
	popErr();
	return null;
}
internal function bb_graphics_SetFont(t_font:c_Image,t_firstChar:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<551>";
	if(!((t_font)!=null)){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<552>";
		if(!((dbg_object(bb_graphics_context).m_defaultFont)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<553>";
			dbg_object(bb_graphics_context).m_defaultFont=bb_graphics_LoadImage("mojo_font.png",96,2);
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<555>";
		t_font=dbg_object(bb_graphics_context).m_defaultFont;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<556>";
		t_firstChar=32;
	}
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<558>";
	dbg_object(bb_graphics_context).m_font=t_font;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<559>";
	dbg_object(bb_graphics_context).m_firstChar=t_firstChar;
	popErr();
	return 0;
}
var bb_audio_device:gxtkAudio;
internal function bb_audio_SetAudioDevice(t_dev:gxtkAudio):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/audio.monkey<22>";
	bb_audio_device=t_dev;
	popErr();
	return 0;
}
class c_InputDevice extends Object{
	internal var m__joyStates:Array=new_object_array(4);
	public function m_InputDevice_new():c_InputDevice{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<26>";
		for(var t_i:int=0;t_i<4;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<27>";
			dbg_array(m__joyStates,t_i)[dbg_index]=(new c_JoyState).m_JoyState_new();
		}
		popErr();
		return this;
	}
	internal var m__keyDown:Array=new_bool_array(512);
	internal var m__keyHitPut:int=0;
	internal var m__keyHitQueue:Array=new_number_array(33);
	internal var m__keyHit:Array=new_number_array(512);
	public function p_PutKeyHit(t_key:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<237>";
		if(m__keyHitPut==m__keyHitQueue.length){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<238>";
		dbg_array(m__keyHit,t_key)[dbg_index]+=1;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<239>";
		dbg_array(m__keyHitQueue,m__keyHitPut)[dbg_index]=t_key;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<240>";
		m__keyHitPut+=1;
		popErr();
	}
	public function p_BeginUpdate():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<189>";
		for(var t_i:int=0;t_i<4;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<190>";
			var t_state:c_JoyState=dbg_array(m__joyStates,t_i)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<191>";
			if(!BBGame.Game().PollJoystick(t_i,dbg_object(t_state).m_joyx,dbg_object(t_state).m_joyy,dbg_object(t_state).m_joyz,dbg_object(t_state).m_buttons)){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<191>";
				break;
			}
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<192>";
			for(var t_j:int=0;t_j<32;t_j=t_j+1){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<193>";
				var t_key:int=256+t_i*32+t_j;
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<194>";
				if(dbg_array(dbg_object(t_state).m_buttons,t_j)[dbg_index]){
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<195>";
					if(!dbg_array(m__keyDown,t_key)[dbg_index]){
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<196>";
						dbg_array(m__keyDown,t_key)[dbg_index]=true;
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<197>";
						this.p_PutKeyHit(t_key);
					}
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<200>";
					dbg_array(m__keyDown,t_key)[dbg_index]=false;
				}
			}
		}
		popErr();
	}
	internal var m__charGet:int=0;
	internal var m__charPut:int=0;
	public function p_EndUpdate():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<207>";
		for(var t_i:int=0;t_i<m__keyHitPut;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<208>";
			dbg_array(m__keyHit,dbg_array(m__keyHitQueue,t_i)[dbg_index])[dbg_index]=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<210>";
		m__keyHitPut=0;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<211>";
		m__charGet=0;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<212>";
		m__charPut=0;
		popErr();
	}
	internal var m__charQueue:Array=new_number_array(32);
	public function p_KeyEvent(t_event:int,t_data:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<111>";
		var t_1:int=t_event;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<112>";
		if(t_1==1){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<113>";
			if(!dbg_array(m__keyDown,t_data)[dbg_index]){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<114>";
				dbg_array(m__keyDown,t_data)[dbg_index]=true;
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<115>";
				this.p_PutKeyHit(t_data);
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<116>";
				if(t_data==1){
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<117>";
					dbg_array(m__keyDown,384)[dbg_index]=true;
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<118>";
					this.p_PutKeyHit(384);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<119>";
					if(t_data==384){
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<120>";
						dbg_array(m__keyDown,1)[dbg_index]=true;
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<121>";
						this.p_PutKeyHit(1);
					}
				}
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<124>";
			if(t_1==2){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<125>";
				if(dbg_array(m__keyDown,t_data)[dbg_index]){
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<126>";
					dbg_array(m__keyDown,t_data)[dbg_index]=false;
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<127>";
					if(t_data==1){
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<128>";
						dbg_array(m__keyDown,384)[dbg_index]=false;
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<129>";
						if(t_data==384){
							_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<130>";
							dbg_array(m__keyDown,1)[dbg_index]=false;
						}
					}
				}
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<133>";
				if(t_1==3){
					_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<134>";
					if(m__charPut<m__charQueue.length){
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<135>";
						dbg_array(m__charQueue,m__charPut)[dbg_index]=t_data;
						_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<136>";
						m__charPut+=1;
					}
				}
			}
		}
		popErr();
	}
	internal var m__mouseX:Number=.0;
	internal var m__mouseY:Number=.0;
	internal var m__touchX:Array=new_number_array(32);
	internal var m__touchY:Array=new_number_array(32);
	public function p_MouseEvent(t_event:int,t_data:int,t_x:Number,t_y:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<142>";
		var t_2:int=t_event;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<143>";
		if(t_2==4){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<144>";
			this.p_KeyEvent(1,1+t_data);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<145>";
			if(t_2==5){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<146>";
				this.p_KeyEvent(2,1+t_data);
				popErr();
				return;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<148>";
				if(t_2==6){
				}else{
					popErr();
					return;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<152>";
		m__mouseX=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<153>";
		m__mouseY=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<154>";
		dbg_array(m__touchX,0)[dbg_index]=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<155>";
		dbg_array(m__touchY,0)[dbg_index]=t_y;
		popErr();
	}
	public function p_TouchEvent(t_event:int,t_data:int,t_x:Number,t_y:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<159>";
		var t_3:int=t_event;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<160>";
		if(t_3==7){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<161>";
			this.p_KeyEvent(1,384+t_data);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<162>";
			if(t_3==8){
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<163>";
				this.p_KeyEvent(2,384+t_data);
				popErr();
				return;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<165>";
				if(t_3==9){
				}else{
					popErr();
					return;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<169>";
		dbg_array(m__touchX,t_data)[dbg_index]=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<170>";
		dbg_array(m__touchY,t_data)[dbg_index]=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<171>";
		if(t_data==0){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<172>";
			m__mouseX=t_x;
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<173>";
			m__mouseY=t_y;
		}
		popErr();
	}
	internal var m__accelX:Number=.0;
	internal var m__accelY:Number=.0;
	internal var m__accelZ:Number=.0;
	public function p_MotionEvent(t_event:int,t_data:int,t_x:Number,t_y:Number,t_z:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<178>";
		var t_4:int=t_event;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<179>";
		if(t_4==10){
		}else{
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<183>";
		m__accelX=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<184>";
		m__accelY=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<185>";
		m__accelZ=t_z;
		popErr();
	}
	public function p_KeyHit(t_key:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<52>";
		if(t_key>0 && t_key<512){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<52>";
			popErr();
			return dbg_array(m__keyHit,t_key)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<53>";
		popErr();
		return 0;
	}
	public function p_KeyDown(t_key:int):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<47>";
		if(t_key>0 && t_key<512){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<47>";
			popErr();
			return dbg_array(m__keyDown,t_key)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<48>";
		popErr();
		return false;
	}
	public function p_TouchX(t_index:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<77>";
		if(t_index>=0 && t_index<32){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<77>";
			popErr();
			return dbg_array(m__touchX,t_index)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<78>";
		popErr();
		return 0.0;
	}
	public function p_TouchY(t_index:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<82>";
		if(t_index>=0 && t_index<32){
			_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<82>";
			popErr();
			return dbg_array(m__touchY,t_index)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<83>";
		popErr();
		return 0.0;
	}
}
class c_JoyState extends Object{
	public function m_JoyState_new():c_JoyState{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/inputdevice.monkey<14>";
		popErr();
		return this;
	}
	internal var m_joyx:Array=new_number_array(2);
	internal var m_joyy:Array=new_number_array(2);
	internal var m_joyz:Array=new_number_array(2);
	internal var m_buttons:Array=new_bool_array(32);
}
var bb_input_device:c_InputDevice;
internal function bb_input_SetInputDevice(t_dev:c_InputDevice):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/input.monkey<22>";
	bb_input_device=t_dev;
	popErr();
	return 0;
}
var bb_app__devWidth:int;
var bb_app__devHeight:int;
internal function bb_app_ValidateDeviceWindow(t_notifyApp:Boolean):void{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<57>";
	var t_w:int=bb_app__game.GetDeviceWidth();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<58>";
	var t_h:int=bb_app__game.GetDeviceHeight();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<59>";
	if(t_w==bb_app__devWidth && t_h==bb_app__devHeight){
		popErr();
		return;
	}
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<60>";
	bb_app__devWidth=t_w;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<61>";
	bb_app__devHeight=t_h;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<62>";
	if(t_notifyApp){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<62>";
		bb_app__app.p_OnResize();
	}
	popErr();
}
class c_DisplayMode extends Object{
	internal var m__width:int=0;
	internal var m__height:int=0;
	public function m_DisplayMode_new(t_width:int,t_height:int):c_DisplayMode{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<192>";
		m__width=t_width;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<193>";
		m__height=t_height;
		popErr();
		return this;
	}
	public function m_DisplayMode_new2():c_DisplayMode{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<189>";
		popErr();
		return this;
	}
}
class c_Map extends Object{
	public function m_Map_new():c_Map{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<7>";
		popErr();
		return this;
	}
	internal var m_root:c_Node=null;
	public function p_Compare(t_lhs:int,t_rhs:int):int{
		return 0;
	}
	public function p_FindNode(t_key:int):c_Node{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<157>";
		var t_node:c_Node=m_root;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<159>";
		while((t_node)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<160>";
			var t_cmp:int=this.p_Compare(t_key,dbg_object(t_node).m_key);
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<161>";
			if(t_cmp>0){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<162>";
				t_node=dbg_object(t_node).m_right;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<163>";
				if(t_cmp<0){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<164>";
					t_node=dbg_object(t_node).m_left;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<166>";
					popErr();
					return t_node;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<169>";
		popErr();
		return t_node;
	}
	public function p_Contains(t_key:int):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<25>";
		var t_:Boolean=this.p_FindNode(t_key)!=null;
		popErr();
		return t_;
	}
	public function p_RotateLeft(t_node:c_Node):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<251>";
		var t_child:c_Node=dbg_object(t_node).m_right;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<252>";
		dbg_object(t_node).m_right=dbg_object(t_child).m_left;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<253>";
		if((dbg_object(t_child).m_left)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<254>";
			dbg_object(dbg_object(t_child).m_left).m_parent=t_node;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<256>";
		dbg_object(t_child).m_parent=dbg_object(t_node).m_parent;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<257>";
		if((dbg_object(t_node).m_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<258>";
			if(t_node==dbg_object(dbg_object(t_node).m_parent).m_left){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<259>";
				dbg_object(dbg_object(t_node).m_parent).m_left=t_child;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<261>";
				dbg_object(dbg_object(t_node).m_parent).m_right=t_child;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<264>";
			m_root=t_child;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<266>";
		dbg_object(t_child).m_left=t_node;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<267>";
		dbg_object(t_node).m_parent=t_child;
		popErr();
		return 0;
	}
	public function p_RotateRight(t_node:c_Node):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<271>";
		var t_child:c_Node=dbg_object(t_node).m_left;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<272>";
		dbg_object(t_node).m_left=dbg_object(t_child).m_right;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<273>";
		if((dbg_object(t_child).m_right)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<274>";
			dbg_object(dbg_object(t_child).m_right).m_parent=t_node;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<276>";
		dbg_object(t_child).m_parent=dbg_object(t_node).m_parent;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<277>";
		if((dbg_object(t_node).m_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<278>";
			if(t_node==dbg_object(dbg_object(t_node).m_parent).m_right){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<279>";
				dbg_object(dbg_object(t_node).m_parent).m_right=t_child;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<281>";
				dbg_object(dbg_object(t_node).m_parent).m_left=t_child;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<284>";
			m_root=t_child;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<286>";
		dbg_object(t_child).m_right=t_node;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<287>";
		dbg_object(t_node).m_parent=t_child;
		popErr();
		return 0;
	}
	public function p_InsertFixup(t_node:c_Node):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<212>";
		while(((dbg_object(t_node).m_parent)!=null) && dbg_object(dbg_object(t_node).m_parent).m_color==-1 && ((dbg_object(dbg_object(t_node).m_parent).m_parent)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<213>";
			if(dbg_object(t_node).m_parent==dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_left){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<214>";
				var t_uncle:c_Node=dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_right;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<215>";
				if(((t_uncle)!=null) && dbg_object(t_uncle).m_color==-1){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<216>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<217>";
					dbg_object(t_uncle).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<218>";
					dbg_object(dbg_object(t_uncle).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<219>";
					t_node=dbg_object(t_uncle).m_parent;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<221>";
					if(t_node==dbg_object(dbg_object(t_node).m_parent).m_right){
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<222>";
						t_node=dbg_object(t_node).m_parent;
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<223>";
						this.p_RotateLeft(t_node);
					}
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<225>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<226>";
					dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<227>";
					this.p_RotateRight(dbg_object(dbg_object(t_node).m_parent).m_parent);
				}
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<230>";
				var t_uncle2:c_Node=dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_left;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<231>";
				if(((t_uncle2)!=null) && dbg_object(t_uncle2).m_color==-1){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<232>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<233>";
					dbg_object(t_uncle2).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<234>";
					dbg_object(dbg_object(t_uncle2).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<235>";
					t_node=dbg_object(t_uncle2).m_parent;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<237>";
					if(t_node==dbg_object(dbg_object(t_node).m_parent).m_left){
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<238>";
						t_node=dbg_object(t_node).m_parent;
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<239>";
						this.p_RotateRight(t_node);
					}
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<241>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<242>";
					dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<243>";
					this.p_RotateLeft(dbg_object(dbg_object(t_node).m_parent).m_parent);
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<247>";
		dbg_object(m_root).m_color=1;
		popErr();
		return 0;
	}
	public function p_Set(t_key:int,t_value:c_DisplayMode):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<29>";
		var t_node:c_Node=m_root;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<30>";
		var t_parent:c_Node=null;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<30>";
		var t_cmp:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<32>";
		while((t_node)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<33>";
			t_parent=t_node;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<34>";
			t_cmp=this.p_Compare(t_key,dbg_object(t_node).m_key);
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<35>";
			if(t_cmp>0){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<36>";
				t_node=dbg_object(t_node).m_right;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<37>";
				if(t_cmp<0){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<38>";
					t_node=dbg_object(t_node).m_left;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<40>";
					dbg_object(t_node).m_value=t_value;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<41>";
					popErr();
					return false;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<45>";
		t_node=(new c_Node).m_Node_new(t_key,t_value,-1,t_parent);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<47>";
		if((t_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<48>";
			if(t_cmp>0){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<49>";
				dbg_object(t_parent).m_right=t_node;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<51>";
				dbg_object(t_parent).m_left=t_node;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<53>";
			this.p_InsertFixup(t_node);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<55>";
			m_root=t_node;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<57>";
		popErr();
		return true;
	}
	public function p_Insert(t_key:int,t_value:c_DisplayMode):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<126>";
		var t_:Boolean=this.p_Set(t_key,t_value);
		popErr();
		return t_;
	}
}
class c_IntMap extends c_Map{
	public function m_IntMap_new():c_IntMap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<534>";
		super.m_Map_new();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<534>";
		popErr();
		return this;
	}
	public override function p_Compare(t_lhs:int,t_rhs:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<537>";
		var t_:int=t_lhs-t_rhs;
		popErr();
		return t_;
	}
}
class c_Stack extends Object{
	public function m_Stack_new():c_Stack{
		pushErr();
		popErr();
		return this;
	}
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_Stack_new2(t_data:Array):c_Stack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<13>";
		dbg_object(this).m_data=t_data.slice(0);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<14>";
		dbg_object(this).m_length=t_data.length;
		popErr();
		return this;
	}
	public function p_Push(t_value:c_DisplayMode):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<67>";
		if(m_length==m_data.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<68>";
			m_data=resize_object_array(m_data,m_length*2+10);
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<70>";
		dbg_array(m_data,m_length)[dbg_index]=t_value;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<71>";
		m_length+=1;
		popErr();
	}
	public function p_Push2(t_values:Array,t_offset:int,t_count:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<79>";
		for(var t_i:int=0;t_i<t_count;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<80>";
			this.p_Push(dbg_array(t_values,t_offset+t_i)[dbg_index]);
		}
		popErr();
	}
	public function p_Push3(t_values:Array,t_offset:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<75>";
		this.p_Push2(t_values,t_offset,t_values.length-t_offset);
		popErr();
	}
	public function p_ToArray():Array{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<18>";
		var t_t:Array=new_object_array(m_length);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<19>";
		for(var t_i:int=0;t_i<m_length;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<20>";
			dbg_array(t_t,t_i)[dbg_index]=dbg_array(m_data,t_i)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<22>";
		popErr();
		return t_t;
	}
}
class c_Node extends Object{
	internal var m_key:int=0;
	internal var m_right:c_Node=null;
	internal var m_left:c_Node=null;
	internal var m_value:c_DisplayMode=null;
	internal var m_color:int=0;
	internal var m_parent:c_Node=null;
	public function m_Node_new(t_key:int,t_value:c_DisplayMode,t_color:int,t_parent:c_Node):c_Node{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<364>";
		dbg_object(this).m_key=t_key;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<365>";
		dbg_object(this).m_value=t_value;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<366>";
		dbg_object(this).m_color=t_color;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<367>";
		dbg_object(this).m_parent=t_parent;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<361>";
		popErr();
		return this;
	}
}
var bb_app__displayModes:Array;
var bb_app__desktopMode:c_DisplayMode;
internal function bb_app_DeviceWidth():int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<263>";
	popErr();
	return bb_app__devWidth;
}
internal function bb_app_DeviceHeight():int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<267>";
	popErr();
	return bb_app__devHeight;
}
internal function bb_app_EnumDisplayModes():void{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<33>";
	var t_modes:Array=bb_app__game.GetDisplayModes();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<34>";
	var t_mmap:c_IntMap=(new c_IntMap).m_IntMap_new();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<35>";
	var t_mstack:c_Stack=(new c_Stack).m_Stack_new();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<36>";
	for(var t_i:int=0;t_i<t_modes.length;t_i=t_i+1){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<37>";
		var t_w:int=dbg_object(dbg_array(t_modes,t_i)[dbg_index]).width;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<38>";
		var t_h:int=dbg_object(dbg_array(t_modes,t_i)[dbg_index]).height;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<39>";
		var t_size:int=t_w<<16|t_h;
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<40>";
		if(t_mmap.p_Contains(t_size)){
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<42>";
			var t_mode:c_DisplayMode=(new c_DisplayMode).m_DisplayMode_new(dbg_object(dbg_array(t_modes,t_i)[dbg_index]).width,dbg_object(dbg_array(t_modes,t_i)[dbg_index]).height);
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<43>";
			t_mmap.p_Insert(t_size,t_mode);
			_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<44>";
			t_mstack.p_Push(t_mode);
		}
	}
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<47>";
	bb_app__displayModes=t_mstack.p_ToArray();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<48>";
	var t_mode2:BBDisplayMode=bb_app__game.GetDesktopMode();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<49>";
	if((t_mode2)!=null){
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<50>";
		bb_app__desktopMode=(new c_DisplayMode).m_DisplayMode_new(dbg_object(t_mode2).width,dbg_object(t_mode2).height);
	}else{
		_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<52>";
		bb_app__desktopMode=(new c_DisplayMode).m_DisplayMode_new(bb_app_DeviceWidth(),bb_app_DeviceHeight());
	}
	popErr();
}
var bb_graphics_renderDevice:gxtkGraphics;
internal function bb_graphics_SetMatrix(t_ix:Number,t_iy:Number,t_jx:Number,t_jy:Number,t_tx:Number,t_ty:Number):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<317>";
	dbg_object(bb_graphics_context).m_ix=t_ix;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<318>";
	dbg_object(bb_graphics_context).m_iy=t_iy;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<319>";
	dbg_object(bb_graphics_context).m_jx=t_jx;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<320>";
	dbg_object(bb_graphics_context).m_jy=t_jy;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<321>";
	dbg_object(bb_graphics_context).m_tx=t_tx;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<322>";
	dbg_object(bb_graphics_context).m_ty=t_ty;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<323>";
	dbg_object(bb_graphics_context).m_tformed=((t_ix!=1.0 || t_iy!=0.0 || t_jx!=0.0 || t_jy!=1.0 || t_tx!=0.0 || t_ty!=0.0)?1:0);
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<324>";
	dbg_object(bb_graphics_context).m_matDirty=1;
	popErr();
	return 0;
}
internal function bb_graphics_SetMatrix2(t_m:Array):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<313>";
	bb_graphics_SetMatrix(dbg_array(t_m,0)[dbg_index],dbg_array(t_m,1)[dbg_index],dbg_array(t_m,2)[dbg_index],dbg_array(t_m,3)[dbg_index],dbg_array(t_m,4)[dbg_index],dbg_array(t_m,5)[dbg_index]);
	popErr();
	return 0;
}
internal function bb_graphics_SetColor(t_r:Number,t_g:Number,t_b:Number):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<259>";
	dbg_object(bb_graphics_context).m_color_r=t_r;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<260>";
	dbg_object(bb_graphics_context).m_color_g=t_g;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<261>";
	dbg_object(bb_graphics_context).m_color_b=t_b;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<262>";
	bb_graphics_renderDevice.SetColor(t_r,t_g,t_b);
	popErr();
	return 0;
}
internal function bb_graphics_SetAlpha(t_alpha:Number):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<276>";
	dbg_object(bb_graphics_context).m_alpha=t_alpha;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<277>";
	bb_graphics_renderDevice.SetAlpha(t_alpha);
	popErr();
	return 0;
}
internal function bb_graphics_SetBlend(t_blend:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<285>";
	dbg_object(bb_graphics_context).m_blend=t_blend;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<286>";
	bb_graphics_renderDevice.SetBlend(t_blend);
	popErr();
	return 0;
}
internal function bb_graphics_SetScissor(t_x:Number,t_y:Number,t_width:Number,t_height:Number):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<294>";
	dbg_object(bb_graphics_context).m_scissor_x=t_x;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<295>";
	dbg_object(bb_graphics_context).m_scissor_y=t_y;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<296>";
	dbg_object(bb_graphics_context).m_scissor_width=t_width;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<297>";
	dbg_object(bb_graphics_context).m_scissor_height=t_height;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<298>";
	bb_graphics_renderDevice.SetScissor(((t_x)|0),((t_y)|0),((t_width)|0),((t_height)|0));
	popErr();
	return 0;
}
internal function bb_graphics_BeginRender():int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<220>";
	bb_graphics_renderDevice=bb_graphics_device;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<221>";
	dbg_object(bb_graphics_context).m_matrixSp=0;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<222>";
	bb_graphics_SetMatrix(1.0,0.0,0.0,1.0,0.0,0.0);
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<223>";
	bb_graphics_SetColor(255.0,255.0,255.0);
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<224>";
	bb_graphics_SetAlpha(1.0);
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<225>";
	bb_graphics_SetBlend(0);
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<226>";
	bb_graphics_SetScissor(0.0,0.0,(bb_app_DeviceWidth()),(bb_app_DeviceHeight()));
	popErr();
	return 0;
}
internal function bb_graphics_EndRender():int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<230>";
	bb_graphics_renderDevice=null;
	popErr();
	return 0;
}
class c_BBGameEvent extends Object{
}
internal function bb_app_EndApp():void{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<259>";
	error("");
	popErr();
}
class c_TRender extends Object{
	public function m_TRender_new():c_TRender{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<28>";
		popErr();
		return this;
	}
	internal static var m_shader2D:c_IShader2D;
	internal static var m_render:c_TRender;
	public function p_GraphicsInit(t_flags:int):int{
		return 0;
	}
	internal static var m_draw_list:c_List3;
	internal static var m_width:int;
	internal static var m_height:int;
	public static function m_UpdateWorld(t_anim_speed:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<130>";
		c_CollisionInfo.m_UpdateCollisions();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<134>";
		var t_first:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<135>";
		var t_last:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<139>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<139>";
		var t_:c_Enumerator2=c_TEntity.m_entity_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<139>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<139>";
			var t_mesh:c_TEntity=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<141>";
			if(((dbg_object(t_mesh).m_anim)!=0) && dbg_object(t_mesh).m_anim_update==1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<143>";
				var t_culltest:Boolean=((t_mesh) as c_TMesh).p_GetCulled();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<146>";
				t_first=dbg_array(dbg_object(t_mesh).m_anim_seqs_first,dbg_object(t_mesh).m_anim_seq)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<147>";
				t_last=dbg_array(dbg_object(t_mesh).m_anim_seqs_last,dbg_object(t_mesh).m_anim_seq)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<149>";
				var t_anim_start:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<151>";
				if(dbg_object(t_mesh).m_anim_trans>0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<153>";
					dbg_object(t_mesh).m_anim_trans=dbg_object(t_mesh).m_anim_trans-1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<154>";
					if(dbg_object(t_mesh).m_anim_trans==1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<154>";
						t_anim_start=1;
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<158>";
				if(dbg_object(t_mesh).m_anim_trans>0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<160>";
					var t_r:Number=1.0-dbg_object(t_mesh).m_anim_time;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<161>";
					t_r=t_r/(dbg_object(t_mesh).m_anim_trans);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<162>";
					dbg_object(t_mesh).m_anim_time=dbg_object(t_mesh).m_anim_time+t_r;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<164>";
					if(dbg_object(t_mesh).m_anim==1 && t_culltest==false){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<166>";
						c_TAnimation.m_AnimateMesh2(t_mesh,dbg_object(t_mesh).m_anim_time,t_first,t_last);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<168>";
						if(dbg_object(t_mesh).m_anim==2 && t_culltest==false){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<170>";
							c_TAnimation.m_AnimateVertex(t_mesh,dbg_object(t_mesh).m_anim_time,t_first,t_last);
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<174>";
					if(t_anim_start==1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<174>";
						dbg_object(t_mesh).m_anim_time=(t_first);
					}
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<178>";
					if(dbg_object(t_mesh).m_anim==1 && t_culltest==false){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<180>";
						c_TAnimation.m_AnimateMesh(t_mesh,dbg_object(t_mesh).m_anim_time,t_first,t_last);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<182>";
						if(dbg_object(t_mesh).m_anim==2 && t_culltest==false){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<184>";
							c_TAnimation.m_AnimateVertex(t_mesh,dbg_object(t_mesh).m_anim_time,t_first,t_last);
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<186>";
							if(dbg_object(t_mesh).m_anim==4){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<188>";
								c_TBone.m_UpdateBoneChildren(t_mesh);
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<190>";
								if(t_culltest==false){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<190>";
									c_TAnimation.m_VertexDeform((t_mesh) as c_TMesh);
								}
							}
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<194>";
					if(dbg_object(t_mesh).m_anim_mode==0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<196>";
						dbg_object(t_mesh).m_anim_update=0;
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<198>";
						if(dbg_object(t_mesh).m_anim_mode==1){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<200>";
							dbg_object(t_mesh).m_anim_time=dbg_object(t_mesh).m_anim_time+dbg_object(t_mesh).m_anim_speed*t_anim_speed;
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<201>";
							if(dbg_object(t_mesh).m_anim_time>(t_last)){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<202>";
								dbg_object(t_mesh).m_anim_time=(t_first)+(dbg_object(t_mesh).m_anim_time-(t_last));
							}
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<205>";
							if(dbg_object(t_mesh).m_anim_mode==2){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<207>";
								if(dbg_object(t_mesh).m_anim_dir==1){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<208>";
									dbg_object(t_mesh).m_anim_time=dbg_object(t_mesh).m_anim_time+dbg_object(t_mesh).m_anim_speed*t_anim_speed;
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<209>";
									if(dbg_object(t_mesh).m_anim_time>(t_last)){
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<210>";
										dbg_object(t_mesh).m_anim_time=dbg_object(t_mesh).m_anim_time-dbg_object(t_mesh).m_anim_speed*t_anim_speed;
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<211>";
										dbg_object(t_mesh).m_anim_dir=-1;
									}
								}
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<215>";
								if(dbg_object(t_mesh).m_anim_dir==-1){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<216>";
									dbg_object(t_mesh).m_anim_time=dbg_object(t_mesh).m_anim_time-dbg_object(t_mesh).m_anim_speed*t_anim_speed;
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<217>";
									if(dbg_object(t_mesh).m_anim_time<(t_first)){
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<218>";
										dbg_object(t_mesh).m_anim_time=dbg_object(t_mesh).m_anim_time+dbg_object(t_mesh).m_anim_speed*t_anim_speed;
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<219>";
										dbg_object(t_mesh).m_anim_dir=1;
									}
								}
							}else{
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<223>";
								if(dbg_object(t_mesh).m_anim_mode==3){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<225>";
									dbg_object(t_mesh).m_anim_time=dbg_object(t_mesh).m_anim_time+dbg_object(t_mesh).m_anim_speed*t_anim_speed;
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<226>";
									if(dbg_object(t_mesh).m_anim_time>(t_last)){
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<228>";
										dbg_object(t_mesh).m_anim_time=(t_first)+(dbg_object(t_mesh).m_anim_time-(t_last));
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<229>";
										dbg_object(t_mesh).m_anim_mode=0;
									}
								}
							}
						}
					}
				}
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<239>";
			if(((t_mesh) as c_TMesh)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<239>";
				dbg_object((t_mesh) as c_TMesh).m_culled=true;
			}
		}
		popErr();
		return 0;
	}
	internal static var m_tris_rendered:int;
	public function p_ContextReady():Boolean{
		return false;
	}
	public function p_DeleteTexture(t_tex:c_TTexture):int{
		return 0;
	}
	public function p_BindTexture(t_tex:c_TTexture,t_flags:int):c_TTexture{
		return null;
	}
	public function p_BindTextureStack():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<497>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<497>";
		var t_:c_Enumerator10=c_TTexture.m_tex_bind_stack.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<497>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<497>";
			var t_tex:c_TTexture=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<498>";
			if(dbg_object(t_tex).m_bind_flags==-255){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<500>";
				m_render.p_DeleteTexture(t_tex);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<501>";
				t_tex.p_FreeTexture_();
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<503>";
				m_render.p_BindTexture(t_tex,dbg_object(t_tex).m_bind_flags);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<506>";
			dbg_object(t_tex).m_bind_flags=-1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<510>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<510>";
		var t_2:c_Enumerator10=c_TTexture.m_tex_bind_stack.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<510>";
		while(t_2.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<510>";
			var t_tex2:c_TTexture=t_2.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<511>";
			if(dbg_object(t_tex2).m_freeMemoryAfterBind){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<512>";
				dbg_object(t_tex2).m_pixmap.p_FreePixmap();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<513>";
				if(true){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<513>";
					print("..freeTextureMemory:"+dbg_object(t_tex2).m_file);
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<517>";
		c_TTexture.m_tex_bind_stack.p_Clear();
		popErr();
		return 0;
	}
	public function p_Reset():void{
		return;
	}
	public function p_UpdateCamera(t_cam:c_TCamera):int{
		return 0;
	}
	public function p_UpdateLight(t_cam:c_TCamera,t_light:c_TLight):int{
		return 0;
	}
	internal static var m_render_list:c_RenderAlphaList;
	internal static var m_render_alpha_list:c_RenderAlphaList;
	internal static var m_wireframe:int;
	public function p_Render(t_ent:c_TEntity,t_cam:c_TCamera):void{
		return;
	}
	public function p_Finish():void{
		return;
	}
	public function p_RenderCamera(t_cam:c_TCamera,t_skip:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<357>";
		m_render.p_Reset();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<362>";
		if(!((t_skip)!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<364>";
			t_cam.p_Update2(t_cam);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<365>";
			this.p_UpdateCamera(t_cam);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<370>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<370>";
		var t_:c_Enumerator13=c_TLight.m_light_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<370>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<370>";
			var t_light:c_TLight=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<372>";
			this.p_UpdateLight(t_cam,t_light);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<378>";
		m_render_list.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<379>";
		m_render_alpha_list.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<382>";
		var t_mesh:c_TMesh=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<383>";
		var t_alpha_count:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<384>";
		var t_wireFrameIsEnabled:int=m_wireframe;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<386>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<386>";
		var t_2:c_Enumerator2=c_TEntity.m_entity_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<386>";
		while(t_2.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<386>";
			var t_ent:c_TEntity=t_2.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<389>";
			t_mesh=((t_ent) as c_TMesh);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<391>";
			if((t_mesh)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<394>";
				if(t_mesh.p_Hidden()==true || dbg_object(dbg_object(t_mesh).m_brush).m_alpha==0.0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<394>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<397>";
				if(dbg_object(t_mesh).m_use_cam_layer && dbg_object(t_mesh).m_cam_layer!=t_cam || dbg_object(t_cam).m_use_cam_layer && dbg_object(t_mesh).m_cam_layer!=t_cam){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<397>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<401>";
				t_mesh.p_GetBounds(false);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<405>";
				var t_inview:Number=t_cam.p_EntityInFrustum(t_mesh);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<406>";
				dbg_object(t_mesh).m_distance_nearplane=t_inview;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<411>";
				if(t_inview>0.00001){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<413>";
					dbg_object(t_mesh).m_culled=false;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<415>";
					m_wireframe=m_wireframe|((dbg_object(t_mesh).m_wireframe)?1:0);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<417>";
					if(dbg_object(t_mesh).m_auto_fade==1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<417>";
						t_mesh.p_AutoFade(t_cam);
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<419>";
					if(((t_mesh) as c_IRenderUpdate)!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<421>";
						((t_mesh) as c_IRenderUpdate).p_Update2(t_cam);
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<425>";
					if(t_mesh.p_Alpha()){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<429>";
						dbg_object(t_mesh).m_alpha_order=dbg_object(t_mesh).m_distance_nearplane;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<430>";
						m_render_alpha_list.p_AddLast3(t_mesh);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<434>";
						m_render.p_Render((t_mesh),t_cam);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<437>";
						m_tris_rendered+=dbg_object(t_mesh).m_total_tris;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<441>";
					m_wireframe=t_wireFrameIsEnabled;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<457>";
		m_render_alpha_list.p_Sort(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<460>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<460>";
		var t_3:c_Enumerator14=m_render_alpha_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<460>";
		while(t_3.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<460>";
			t_mesh=t_3.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<462>";
			m_wireframe=m_wireframe|((dbg_object(t_mesh).m_wireframe)?1:0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<464>";
			m_render.p_Render((t_mesh),t_cam);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<466>";
			m_wireframe=t_wireFrameIsEnabled;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<468>";
			m_tris_rendered+=dbg_object(t_mesh).m_total_tris;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<474>";
		this.p_Finish();
		popErr();
	}
	internal static var m_temp_shader:c_TShader;
	internal static var m_alpha_pass:int;
	internal static var m_camera2D:c_TCamera;
	public static function m_RenderDrawList():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<296>";
		if(m_draw_list.p_IsEmpty() || !m_render.p_ContextReady()){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<299>";
		m_render.p_Reset();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<300>";
		m_shader2D.p_SetShader2D();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<305>";
		c_MojoEmulationDevice.m__quadCache.p_FlushCache();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<307>";
		m_alpha_pass=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<308>";
		var t_wireframeIsEnabled:int=m_wireframe;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<309>";
		m_wireframe=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<313>";
		m_render.p_UpdateCamera(m_camera2D);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<316>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<316>";
		var t_:c_Enumerator14=m_draw_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<316>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<316>";
			var t_mesh:c_TMesh=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<318>";
			if(!((t_mesh)!=null)){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<318>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<320>";
			if(((t_mesh) as c_IRenderUpdate)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<322>";
				((t_mesh) as c_IRenderUpdate).p_Update2(m_camera2D);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<327>";
			var t_sp:c_TSprite=((t_mesh) as c_TSprite);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<328>";
			if(dbg_object(t_mesh).m_is_sprite){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<329>";
				dbg_object(t_sp).m_mat_sp.p_Scale(dbg_array(dbg_object(t_sp).m_pixel_scale,0)[dbg_index],dbg_array(dbg_object(t_sp).m_pixel_scale,1)[dbg_index],1.0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<330>";
				t_mesh.p_EntityFX(64);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<334>";
			if(t_mesh.p_Alpha()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<334>";
				dbg_object(t_mesh).m_alpha_order=1.0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<337>";
			m_render.p_Render((t_mesh),m_camera2D);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<338>";
			m_tris_rendered+=dbg_object(t_mesh).m_total_tris;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<342>";
		m_wireframe=t_wireframeIsEnabled;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<344>";
		m_render.p_Finish();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<345>";
		m_draw_list.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<348>";
		m_camera2D.p_CameraClsMode(false,false);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<349>";
		m_camera2D.p_CameraViewport(0,0,m_width,m_height);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<350>";
		m_camera2D.p_SetPixelCamera();
		popErr();
	}
	public function p_RenderWorldFinish():void{
		pushErr();
		popErr();
	}
	public static function m_RenderWorld():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<251>";
		m_tris_rendered=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<254>";
		if(m_render==null || !m_render.p_ContextReady()){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<257>";
		if(c_TTexture.m_tex_bind_stack.p_Length()>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<257>";
			m_render.p_BindTextureStack();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<260>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<260>";
		var t_:c_Enumerator11=c_TCamera.m_cam_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<260>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<260>";
			var t_cam:c_TCamera=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<263>";
			if(t_cam.p_Hidden()==true){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<263>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<265>";
			c_TShader.m_PreProcess(t_cam);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<269>";
			if(((c_TShader.m_g_shader) as c_IShaderRender)==null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<271>";
				m_render.p_RenderCamera(t_cam,0);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<275>";
				m_temp_shader=c_TShader.m_g_shader;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<277>";
				((c_TShader.m_g_shader) as c_IShaderRender).p_Render2(t_cam);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<279>";
				c_TShader.m_g_shader=m_temp_shader;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<283>";
			c_TShader.m_PostProcess(t_cam);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<287>";
		m_RenderDrawList();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<289>";
		m_render.p_RenderWorldFinish();
		popErr();
	}
	public function p_GetVersion():Number{
		return 0;
	}
	public function p_UpdateVBO(t_surface:c_TSurface):int{
		return 0;
	}
	internal static var m_vbo_enabled:Boolean;
	public function p_ClearErrors():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<524>";
		popErr();
		return 1;
	}
}
interface c_IShader2D{
	function p_SetShader2D():void;
}
class c_FlashMiniB3D extends c_TRender implements c_IShader2D{
	public function m_FlashMiniB3D_new():c_FlashMiniB3D{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<190>";
		super.m_TRender_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<192>";
		c_TRender.m_shader2D=(this);
		popErr();
		return this;
	}
	internal static var m_driver:Driver3D;
	public function p_ForceFlashTransparency(t_g:gxtkGraphics):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1250>";
		m_driver.ForceDeviceTransparency(t_g);
		popErr();
	}
	public override function p_ContextReady():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<226>";
		var t_:Boolean=m_driver.ContextReady();
		popErr();
		return t_;
	}
	internal var m_render_init:Boolean=false;
	public override function p_GetVersion():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<199>";
		var t_st:String="";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<201>";
		var t_s:String=m_driver.CheckVersion();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<203>";
		var t_num:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<205>";
		for(var t_i:int=0;t_i<=t_s.length-1;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<207>";
			if(dbg_charCodeAt(t_s,t_i)>47 && dbg_charCodeAt(t_s,t_i)<58){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<208>";
				t_st=t_st+String.fromCharCode(dbg_charCodeAt(t_s,t_i));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<209>";
				if(t_num==0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<209>";
					t_num=1;
				}
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<210>";
				if(dbg_charCodeAt(t_s,t_i)==46 || dbg_charCodeAt(t_s,t_i)==44){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<211>";
					if(t_num==2){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<211>";
						break;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<212>";
					t_st=t_st+String.fromCharCode(dbg_charCodeAt(t_s,t_i));
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<213>";
					t_num=2;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<214>";
					if(t_num!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<215>";
						break;
					}
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<219>";
		var t_:Number=parseFloat(t_st);
		popErr();
		return t_;
	}
	public function p_EnableStates():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<748>";
		if(this.p_GetVersion()<11.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<748>";
			error("You will need at least Flash 11 for this to work.");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<750>";
		print("..Context Success");
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<752>";
		m_driver.EnableErrorChecking_(false);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<755>";
		print("..FLASH STAGE3D VERSION:"+String(this.p_GetVersion()));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<757>";
		m_driver.EnableErrorChecking_(true);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<761>";
		m_driver.context3d.setDepthTest(true,Context3DCompareMode.LESS_EQUAL);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<762>";
		m_driver.context3d.setCulling(Context3DTriangleFace.NONE);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<764>";
		c_TShader.m_LoadDefaultShader2((new c_MultiShader).m_MultiShader_new());
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<766>";
		((c_TRender.m_render) as c_FlashMiniB3D).p_ForceFlashTransparency(bb_graphics_GetGraphicsDevice());
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<767>";
		m_driver.context3d.clear(0.0,0.0,0.0,0.0,1.0,0,Context3DClearMask.ALL);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<769>";
		m_render_init=true;
		popErr();
	}
	internal static var m_last_texture:c_TTexture;
	internal static var m_last_sprite:c_TSurface;
	internal var m_last_shader:c_TShaderFlash=null;
	internal var m_last_effect:c_EffectState=(new c_EffectState).m_EffectState_new();
	public override function p_Reset():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<232>";
		if(!m_render_init){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<232>";
			this.p_EnableStates();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<236>";
		m_last_texture=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<237>";
		m_last_sprite=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<238>";
		m_last_shader=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<239>";
		c_TRender.m_alpha_pass=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<240>";
		m_last_effect.p_SetNull();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<242>";
		m_driver.context3d.setDepthTest(true,Context3DCompareMode.LESS_EQUAL);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<244>";
		c_TShader.m_DefaultShader();
		popErr();
	}
	internal static var m_current_cam:c_TCamera;
	internal static var m_alpha_list:c_SurfaceAlphaList;
	internal var m_surf_buf_id:int=0;
	internal var m_abuf_map:c_ArrayIntMap=(new c_ArrayIntMap).m_ArrayIntMap_new();
	internal var m_vbuf_map:c_ArrayIntMap=(new c_ArrayIntMap).m_ArrayIntMap_new();
	internal var m_ibuf_map:c_ArrayIntMap2=(new c_ArrayIntMap2).m_ArrayIntMap_new();
	public static function m_GetFlashError():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<776>";
		popErr();
		return 0;
	}
	public override function p_UpdateVBO(t_surf:c_TSurface):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<791>";
		var t_vbuffer:VertexBuffer3D=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<791>";
		var t_ibuffer:IndexBuffer3D=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<791>";
		var t_abuffer:VertexBuffer3D=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<792>";
		var t_createFlag:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<795>";
		if(dbg_object(t_surf).m_reset_vbo==0 && dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<795>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<798>";
		var t_update:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<802>";
		if(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<804>";
			m_surf_buf_id+=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<805>";
			if(m_surf_buf_id==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<805>";
				m_surf_buf_id=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<806>";
			dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]=m_surf_buf_id;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<809>";
			t_createFlag=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<812>";
			t_update=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<817>";
		if(dbg_object(t_surf).m_reset_vbo<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<817>";
			t_createFlag=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<817>";
			dbg_object(t_surf).m_reset_vbo=255;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<823>";
		if(((dbg_object(t_surf).m_reset_vbo&1)!=0) || ((dbg_object(t_surf).m_reset_vbo&2)!=0) || ((dbg_object(t_surf).m_reset_vbo&4)!=0) || ((dbg_object(t_surf).m_reset_vbo&8)!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<826>";
			if(dbg_object(t_surf).m_vbo_dyn && dbg_object(t_surf).m_vert_anim.length==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<827>";
				if(t_createFlag){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<828>";
					if((t_abuffer)!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<828>";
						t_abuffer.dispose();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<829>";
					t_abuffer=m_driver.context3d.createVertexBuffer(dbg_object(t_surf).m_no_verts,16);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<830>";
					m_abuf_map.p_Set3(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index],t_abuffer);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<837>";
					t_abuffer=m_abuf_map.p_Get2(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<840>";
				m_driver.UploadVertexFromDataBuffer(t_abuffer,dbg_object(dbg_object(t_surf).m_vert_data).m_buf,0,0,dbg_object(t_surf).m_no_verts);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<842>";
				t_update=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<848>";
			if(dbg_object(t_surf).m_vbo_dyn && dbg_object(t_surf).m_vert_anim.length!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<849>";
				if(t_createFlag){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<850>";
					if((t_abuffer)!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<850>";
						t_abuffer.dispose();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<851>";
					t_abuffer=m_driver.context3d.createVertexBuffer(dbg_object(t_surf).m_no_verts,3);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<852>";
					m_abuf_map.p_Set3(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index],t_abuffer);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<856>";
					t_abuffer=m_abuf_map.p_Get2(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<859>";
				m_driver.UploadVertexFromDataBuffer(t_abuffer,dbg_object(dbg_array(dbg_object(t_surf).m_vert_anim,dbg_object(t_surf).m_anim_frame)[dbg_index]).m_buf,0,0,dbg_object(t_surf).m_no_verts);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<860>";
				t_update=1;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<865>";
				if(t_createFlag){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<867>";
					if((t_vbuffer)!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<867>";
						t_vbuffer.dispose();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<868>";
					if((t_ibuffer)!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<868>";
						t_ibuffer.dispose();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<870>";
					t_vbuffer=m_driver.context3d.createVertexBuffer(dbg_object(t_surf).m_no_verts,16);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<872>";
					t_ibuffer=m_driver.context3d.createIndexBuffer(dbg_object(t_surf).m_no_tris*3);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<874>";
					m_vbuf_map.p_Set3(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index],t_vbuffer);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<875>";
					m_ibuf_map.p_Set4(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index],t_ibuffer);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<877>";
					t_vbuffer=m_vbuf_map.p_Get2(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<881>";
				m_driver.UploadVertexFromDataBuffer(t_vbuffer,dbg_object(dbg_object(t_surf).m_vert_data).m_buf,0,0,dbg_object(t_surf).m_no_verts);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<882>";
				t_update=1;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<887>";
		if((dbg_object(t_surf).m_reset_vbo&16)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<889>";
			t_ibuffer=m_ibuf_map.p_Get2(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<890>";
			if((t_ibuffer)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<890>";
				m_driver.UploadIndexFromDataBuffer(t_ibuffer,dbg_object(dbg_object(t_surf).m_tris).m_buf,0,0,dbg_object(t_surf).m_no_tris*3);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<891>";
			t_update=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<894>";
		if(true && ((m_GetFlashError())!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<894>";
			print("*error: vbo update");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<897>";
		dbg_object(t_surf).m_reset_vbo=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<899>";
		popErr();
		return t_update;
	}
	internal var m_effect:c_EffectState=(new c_EffectState).m_EffectState_new();
	internal var m_texdata:c_TexData=(new c_TexData).m_TexData_new();
	internal var m_shader:c_TShaderFlash=null;
	internal var m_tex_map:c_ArrayIntMap3=(new c_ArrayIntMap3).m_ArrayIntMap_new();
	internal static var m_last_tex_count:int;
	internal static var m_null_tex:c_TTexture;
	internal static var m_temp_cam:c_Matrix;
	internal static var m_temp_mat:c_Matrix;
	public override function p_Render(t_ent:c_TEntity,t_cam:c_TCamera):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<255>";
		m_current_cam=t_cam;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<257>";
		var t_mesh:c_TMesh=((t_ent) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<259>";
		if(!((t_mesh)!=null)){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<261>";
		var t_name:String=t_ent.p_EntityName();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<263>";
		var t_fog:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<264>";
		if(dbg_object(t_cam).m_fog_mode==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<264>";
			t_fog=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<267>";
		var t_anim_surf2:c_TSurface=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<268>";
		var t_ccc:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<271>";
		var t_temp_list:c_List2=dbg_object(t_mesh).m_surf_list;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<272>";
		m_alpha_list.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<276>";
		for(var t_alphaloop:int=c_TRender.m_alpha_pass;t_alphaloop<=1;t_alphaloop=t_alphaloop+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<278>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<278>";
			var t_:c_Enumerator6=t_temp_list.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<278>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<278>";
				var t_surf:c_TSurface=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<279>";
				t_ccc+=1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<284>";
				if(dbg_object(t_surf).m_no_verts==0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<284>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<285>";
				if(dbg_object(t_surf).m_alpha_enable && t_alphaloop<1){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<287>";
					m_alpha_list.p_AddLast2(t_surf);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<288>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<296>";
				var t_vbo:int=1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<299>";
				var t_vbuffer:VertexBuffer3D=null;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<300>";
				var t_ibuffer:IndexBuffer3D=null;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<301>";
				var t_abuffer:VertexBuffer3D=null;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<305>";
				this.p_UpdateVBO(t_surf);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<306>";
				t_vbuffer=m_vbuf_map.p_Get2(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<307>";
				t_ibuffer=m_ibuf_map.p_Get2(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<308>";
				t_abuffer=null;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<310>";
				if((dbg_object(t_mesh).m_anim)!=0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<313>";
					t_anim_surf2=t_mesh.p_GetAnimSurface(t_surf);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<314>";
					t_mesh.p_UpdateVertexAnimFrame(t_anim_surf2,t_surf);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<316>";
					if((t_anim_surf2)!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<319>";
						dbg_object(t_anim_surf2).m_vbo_dyn=true;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<320>";
						this.p_UpdateVBO(t_anim_surf2);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<321>";
						t_abuffer=m_abuf_map.p_Get2(dbg_array(dbg_object(t_anim_surf2).m_vbo_id,0)[dbg_index]);
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<328>";
				m_effect.p_UpdateEffect(t_surf,t_ent,t_cam);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<329>";
				m_texdata.p_UpdateTexture(t_surf,t_ent);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<333>";
				m_shader=((c_TShader.m_g_shader) as c_TShaderFlash);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<334>";
				if(((m_shader) as c_MultiShader)!=null){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<335>";
					if((dbg_object(m_effect).m_use_full_bright)!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<336>";
						if((dbg_object(m_texdata).m_uv_clamp)!=0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<337>";
							m_shader=((m_shader) as c_MultiShader).p_GetShader(0);
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<339>";
							m_shader=((m_shader) as c_MultiShader).p_GetShader(1);
						}
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<342>";
						if((dbg_object(m_texdata).m_uv_clamp)!=0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<343>";
							m_shader=((m_shader) as c_MultiShader).p_GetShader(2);
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<345>";
							m_shader=((m_shader) as c_MultiShader).p_GetShader(3);
						}
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<350>";
				m_shader.p_Update12();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<356>";
				var t_skip_state:Boolean=false;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<357>";
				if(m_last_sprite==t_surf){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<358>";
					t_skip_state=true;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<360>";
					m_last_sprite=t_surf;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<371>";
				if(t_skip_state==false){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<374>";
					var t_write:Boolean=true;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<375>";
					if(dbg_object(m_effect).m_use_depth_write==0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<375>";
						t_write=false;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<377>";
					if(dbg_object(m_effect).m_use_depth_test!=dbg_object(m_last_effect).m_use_depth_test || dbg_object(m_effect).m_use_depth_write!=dbg_object(m_last_effect).m_use_depth_write){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<378>";
						if(dbg_object(m_effect).m_use_depth_test==0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<378>";
							m_driver.context3d.setDepthTest(t_write,Context3DCompareMode.ALWAYS);
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<378>";
							m_driver.context3d.setDepthTest(t_write,Context3DCompareMode.LESS_EQUAL);
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<382>";
					if(dbg_object(m_effect).m_use_backface_culling==0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<383>";
						m_driver.context3d.setCulling(Context3DTriangleFace.NONE);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<385>";
						m_driver.context3d.setCulling(Context3DTriangleFace.FRONT);
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<389>";
					var t_1:int=dbg_object(m_effect).m_blend;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<390>";
					if(t_1==0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<391>";
						m_driver.context3d.setBlendFactors(Context3DBlendFactor.SOURCE_ALPHA,Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<392>";
						if(t_1==1){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<393>";
							m_driver.context3d.setBlendFactors(Context3DBlendFactor.ONE,Context3DBlendFactor.ONE_MINUS_SOURCE_ALPHA);
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<394>";
							if(t_1==2){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<396>";
								m_driver.context3d.setBlendFactors(Context3DBlendFactor.DESTINATION_COLOR,Context3DBlendFactor.ZERO);
							}else{
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<397>";
								if(t_1==3){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<399>";
									m_driver.context3d.setBlendFactors(Context3DBlendFactor.SOURCE_ALPHA,Context3DBlendFactor.ONE);
								}else{
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<400>";
									if(t_1==4){
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<402>";
										m_driver.context3d.setBlendFactors(Context3DBlendFactor.ONE,Context3DBlendFactor.ONE);
									}else{
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<404>";
										m_driver.context3d.setBlendFactors(Context3DBlendFactor.ONE,Context3DBlendFactor.ZERO);
									}
								}
							}
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<409>";
					if(!(dbg_object(t_mesh).m_anim==1 || dbg_object(t_surf).m_vbo_dyn==true)){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<410>";
						m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_vertcoords,t_vbuffer,0,Context3DVertexBufferFormat.FLOAT_3);
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<413>";
					if(dbg_object(dbg_object(m_shader).m_u).m_normals>-1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<413>";
						m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_normals,t_vbuffer,4,Context3DVertexBufferFormat.FLOAT_3);
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<414>";
					if(dbg_object(dbg_object(m_shader).m_u).m_colors>-1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<414>";
						m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_colors,t_vbuffer,8,Context3DVertexBufferFormat.FLOAT_4);
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<422>";
				if(((t_abuffer)!=null) && (((dbg_object(t_mesh).m_anim)!=0) || dbg_object(t_surf).m_vbo_dyn || ((t_anim_surf2)!=null))){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<425>";
					if((dbg_object(t_anim_surf2).m_vert_anim).length!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<427>";
						m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_vertcoords,t_abuffer,0,Context3DVertexBufferFormat.FLOAT_3);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<431>";
						m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_vertcoords,t_abuffer,0,Context3DVertexBufferFormat.FLOAT_3);
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<436>";
				if(t_abuffer==null && dbg_object(t_surf).m_vbo_dyn){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<437>";
					t_abuffer=m_abuf_map.p_Get2(dbg_array(dbg_object(t_surf).m_vbo_id,0)[dbg_index]);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<438>";
					m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_vertcoords,t_abuffer,0,Context3DVertexBufferFormat.FLOAT_3);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<444>";
				var t_tex_count:int=dbg_object(m_texdata).m_tex_count;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<446>";
				for(var t_ix:int=0;t_ix<=t_tex_count-1;t_ix=t_ix+1){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<448>";
					if(dbg_array(dbg_object(m_texdata).m_texture,t_ix)[dbg_index]!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<452>";
						if(m_last_texture==dbg_array(dbg_object(m_texdata).m_texture,t_ix)[dbg_index]){
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<460>";
							m_last_texture=dbg_array(dbg_object(m_texdata).m_texture,t_ix)[dbg_index];
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<462>";
							if(dbg_object(dbg_object(m_shader).m_u).m_texcoords0>-1){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<462>";
								m_driver.context3d.setTextureAt(t_ix,m_tex_map.p_Get2(dbg_object(m_last_texture).m_tex_id));
							}
						}
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<470>";
						if(!t_skip_state){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<480>";
							if((dbg_array(dbg_object(m_texdata).m_tex_flags,t_ix)[dbg_index]&8)!=0){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<481>";
								if((dbg_array(dbg_object(m_texdata).m_tex_smooth,t_ix)[dbg_index])!=0){
								}
							}else{
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<489>";
								if((dbg_array(dbg_object(m_texdata).m_tex_smooth,t_ix)[dbg_index])!=0){
								}
							}
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<499>";
							if((dbg_array(dbg_object(m_texdata).m_tex_flags,t_ix)[dbg_index]&16)!=0 || (dbg_array(dbg_object(m_texdata).m_tex_flags,t_ix)[dbg_index]&32)!=0){
							}
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<532>";
							if(dbg_array(dbg_object(m_texdata).m_tex_coords,t_ix)[dbg_index]==0 && dbg_object(dbg_object(m_shader).m_u).m_texcoords0>-1){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<534>";
								m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_texcoords0,t_vbuffer,12,Context3DVertexBufferFormat.FLOAT_2);
							}
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<536>";
							if(dbg_array(dbg_object(m_texdata).m_tex_coords,t_ix)[dbg_index]==1 && dbg_object(dbg_object(m_shader).m_u).m_texcoords1>-1){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<538>";
								m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_texcoords1,t_vbuffer,14,Context3DVertexBufferFormat.FLOAT_2);
							}
						}
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<548>";
						m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_array(dbg_object(dbg_object(m_shader).m_u).m_tex_position,t_ix)[dbg_index],[dbg_array(dbg_object(m_texdata).m_tex_u_pos,t_ix)[dbg_index],dbg_array(dbg_object(m_texdata).m_tex_v_pos,t_ix)[dbg_index],Math.cos((dbg_array(dbg_object(m_texdata).m_tex_ang,t_ix)[dbg_index])*D2R),Math.sin((dbg_array(dbg_object(m_texdata).m_tex_ang,t_ix)[dbg_index])*D2R)],0);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<550>";
						m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_array(dbg_object(dbg_object(m_shader).m_u).m_tex_scale,t_ix)[dbg_index],[dbg_array(dbg_object(m_texdata).m_tex_u_scale,t_ix)[dbg_index],dbg_array(dbg_object(m_texdata).m_tex_v_scale,t_ix)[dbg_index],0.0,0.0],0);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<559>";
						if((dbg_array(dbg_object(m_texdata).m_tex_flags,t_ix)[dbg_index]&128)!=0){
						}
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<569>";
				if(dbg_object(m_texdata).m_tex_count==0 && (dbg_object(dbg_object(m_shader).m_u).m_texcoords0>-1 || dbg_object(dbg_object(m_shader).m_u).m_texcoords1>-1)){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<571>";
					for(var t_ix2:int=0;t_ix2<=m_last_tex_count-1;t_ix2=t_ix2+1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<573>";
						m_driver.context3d.setTextureAt(t_ix2,null);
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<577>";
					m_last_texture=null;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<578>";
					m_driver.context3d.setTextureAt(0,m_tex_map.p_Get2(dbg_object(m_null_tex).m_tex_id));
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<579>";
					if(dbg_object(dbg_object(m_shader).m_u).m_texcoords0>-1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<580>";
						m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_texcoords0,t_vbuffer,12,Context3DVertexBufferFormat.FLOAT_2);
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<582>";
					if(dbg_object(dbg_object(m_shader).m_u).m_texcoords1>-1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<583>";
						m_driver.context3d.setVertexBufferAt(dbg_object(dbg_object(m_shader).m_u).m_texcoords1,t_vbuffer,20,Context3DVertexBufferFormat.FLOAT_2);
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<588>";
				m_last_tex_count=dbg_object(m_texdata).m_tex_count;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<596>";
				m_temp_cam.p_Overwrite(dbg_object(t_cam).m_projview_mat);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<598>";
				if(dbg_object(t_mesh).m_is_sprite==false){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<599>";
					m_temp_cam.p_Multiply4(dbg_object(t_ent).m_mat);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<601>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_m_matrix,bb_flash11_AGALMatrix(dbg_object(t_ent).m_mat),0);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<602>";
					m_temp_mat.p_Overwrite(dbg_object(t_ent).m_mat);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<604>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_n_matrix,bb_flash11_AGALMatrix(m_temp_mat.p_Inverse().p_Transpose()),0);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<606>";
					m_temp_cam.p_Multiply4(dbg_object((t_mesh) as c_TSprite).m_mat_sp);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<608>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_m_matrix,bb_flash11_AGALMatrix(dbg_object((t_mesh) as c_TSprite).m_mat_sp),0);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<609>";
					m_temp_mat.p_Overwrite(dbg_object((t_mesh) as c_TSprite).m_mat_sp);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<611>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_n_matrix,bb_flash11_AGALMatrix(m_temp_mat.p_Inverse().p_Transpose()),0);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<616>";
				m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_p_matrix,bb_flash11_AGALMatrix(m_temp_cam),0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<620>";
				if(dbg_array(dbg_object(dbg_object(m_shader).m_u).m_light_matrix,0)[dbg_index]>-1 && c_TLight.m_light_list.p_IsEmpty()==false && dbg_object(m_effect).m_use_full_bright==0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<621>";
					var t_ll:c_TLight=c_TLight.m_light_list.p_First();
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<622>";
					m_temp_mat.p_Overwrite(dbg_object(t_ll).m_mat);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<624>";
					if(dbg_object(t_ll).m_light_type==1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<625>";
						dbg_array(dbg_array(dbg_object(m_temp_mat).m_grid,3)[dbg_index],0)[dbg_index]=0.0;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<625>";
						dbg_array(dbg_array(dbg_object(m_temp_mat).m_grid,3)[dbg_index],1)[dbg_index]=0.0;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<625>";
						dbg_array(dbg_array(dbg_object(m_temp_mat).m_grid,3)[dbg_index],2)[dbg_index]=1.0;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<626>";
						m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_lightflag,[1.0,0.0,0.0,0.0],0);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<628>";
						if(dbg_object(t_ll).m_light_type==2){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<628>";
							m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_lightflag,[0.0,1.0,0.0,0.0],0);
						}
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<629>";
						if(dbg_object(t_ll).m_light_type==3){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<629>";
							m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_lightflag,[0.0,0.0,1.0,0.0],0);
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<635>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_array(dbg_object(dbg_object(m_shader).m_u).m_light_matrix,0)[dbg_index],bb_flash11_AGALMatrix(m_temp_mat),0);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<636>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_array(dbg_object(dbg_object(m_shader).m_u).m_light_color,0)[dbg_index],[dbg_object(t_ll).m_red,dbg_object(t_ll).m_green,dbg_object(t_ll).m_blue,1.0],0);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<637>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_array(dbg_object(dbg_object(m_shader).m_u).m_light_att,0)[dbg_index],[dbg_object(t_ll).m_const_att,dbg_object(t_ll).m_lin_att,dbg_object(t_ll).m_quad_att,dbg_object(t_ll).m_actual_range],0);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<639>";
					m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_array(dbg_object(dbg_object(m_shader).m_u).m_light_color,0)[dbg_index],[1.0,1.0,1.0,1.0],0);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<645>";
				m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_colorflag,[1.0-(dbg_object(m_effect).m_use_vertex_colors),0.0,0.0,0.0],0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<646>";
				m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_base_color,dbg_object(m_effect).m_diffuse,0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<647>";
				m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_ambient_color,dbg_object(m_effect).m_ambient,0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<649>";
				m_driver.UploadConstantsFromArray(Context3DProgramType.VERTEX,dbg_object(dbg_object(m_shader).m_u).m_miscflag,[0.5*(dbg_object(m_effect).m_use_alpha_test),0.0,0.0,0.0],0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<650>";
				m_driver.UploadConstantsFromArray(Context3DProgramType.FRAGMENT,dbg_object(dbg_object(m_shader).m_u).m_miscflag,[0.5*(dbg_object(m_effect).m_use_alpha_test),0.0,0.0,0.0],0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<654>";
				if(m_shader!=m_last_shader){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<655>";
					m_driver.context3d.setProgram(dbg_object(m_shader).m_program_set);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<656>";
					m_last_shader=m_shader;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<659>";
				if((c_TRender.m_wireframe)!=0){
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<664>";
					if((t_vbo)!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<666>";
						try{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<667>";
							m_driver.context3d.drawTriangles(t_ibuffer,0,dbg_object(t_surf).m_no_tris);
						}catch(t_e:Error){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<669>";
							print("**"+t_e.toString());
						}
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<675>";
				m_last_effect.p_Overwrite4(m_effect);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<681>";
			if(!((m_alpha_list)!=null)){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<681>";
				break;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<682>";
			t_temp_list=(m_alpha_list);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<686>";
		t_temp_list=null;
		popErr();
	}
	public override function p_Finish():void{
		pushErr();
		popErr();
	}
	public override function p_RenderWorldFinish():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<702>";
		m_driver.PresentToDevice(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<703>";
		m_driver.context3d.clear(0.0,0.0,0.0,0.0,1.0,0,Context3DClearMask.ALL);
		popErr();
	}
	public override function p_GraphicsInit(t_flags:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<710>";
		c_TRender.m_render=((new c_FlashMiniB3D).m_FlashMiniB3D_new());
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<711>";
		c_TRender.m_width=bb_app_DeviceWidth();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<712>";
		c_TRender.m_height=bb_app_DeviceHeight();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<715>";
		m_driver.InitContext(c_TRender.m_width,c_TRender.m_height,0,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<718>";
		c_TTexture.m_TextureFilter("",9);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<727>";
		c_TPixmapFlash.m_Init();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<730>";
		m_null_tex=bb_functions_CreateTexture(1,1,2,1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<731>";
		c_TexData.m_null_tex=m_null_tex;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<734>";
		c_TRender.m_vbo_enabled=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<739>";
		c_TEntity.m_global_mat.p_LoadIdentity();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<741>";
		popErr();
		return 1;
	}
	public override function p_DeleteTexture(t_tex:c_TTexture):int{
		pushErr();
		popErr();
		return 0;
	}
	internal var m_tex_map_id:int=0;
	public override function p_BindTexture(t_tex:c_TTexture,t_flags:int):c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<972>";
		c_TRender.m_render.p_ClearErrors();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<978>";
		if((t_flags&4)!=0){
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<985>";
		var t_width:int=dbg_object(dbg_object(t_tex).m_pixmap).m_width;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<986>";
		var t_height:int=dbg_object(dbg_object(t_tex).m_pixmap).m_height;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<987>";
		var t_ftex:Texture=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<989>";
		if(((dbg_object(dbg_object(t_tex).m_pixmap).m_bind)!=0) && ((dbg_object(t_tex).m_tex_id)!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<989>";
			popErr();
			return t_tex;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<990>";
		if(t_width==0 || t_height==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<990>";
			popErr();
			return t_tex;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<992>";
		if(!((dbg_object(t_tex).m_tex_id)!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<993>";
			m_tex_map_id+=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<994>";
			dbg_object(t_tex).m_tex_id=m_tex_map_id;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<995>";
			t_ftex=m_driver.context3d.createTexture(t_width,t_height,Context3DTextureFormat.BGRA,false);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<997>";
			m_tex_map.p_Set5(dbg_object(t_tex).m_tex_id,t_ftex);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1002>";
		var t_mipmap:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1002>";
		var t_mip_level:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1003>";
		var t_pix:c_TPixmapFlash=((dbg_object(t_tex).m_pixmap) as c_TPixmapFlash);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1005>";
		if((t_flags&8)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1005>";
			t_mipmap=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1007>";
		do{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1009>";
			var t_uploaded:int=m_driver.UploadTextureData(t_ftex,dbg_object(t_pix).m_pixels,t_mip_level);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1011>";
			if(!((t_uploaded)!=0)){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1012>";
				error("** out of texture memory or no data **");
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1015>";
			if(!((t_mipmap)!=0) || t_width==1 && t_height==1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1015>";
				break;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1016>";
			if(t_width>1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1016>";
				t_width=(((t_width)*0.5)|0);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1017>";
			if(t_height>1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1017>";
				t_height=(((t_height)*0.5)|0);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1019>";
			if(dbg_object(t_tex).m_resize_smooth){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1020>";
				t_pix=((t_pix.p_ResizePixmap(t_width,t_height)) as c_TPixmapFlash);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1022>";
				t_pix=((t_pix.p_ResizePixmapNoSmooth(t_width,t_height)) as c_TPixmapFlash);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1025>";
			t_mip_level+=1;
		}while(!(false));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1029>";
		dbg_object(t_tex).m_no_mipmaps=t_mip_level;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1030>";
		dbg_object(t_tex).m_pixmap.p_SetBind();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1032>";
		popErr();
		return t_tex;
	}
	public override function p_UpdateLight(t_cam:c_TCamera,t_light:c_TLight):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1038>";
		popErr();
		return 0;
	}
	internal static var m_fastQuad:c_TMesh;
	internal static var m_shader2d_:c_TShaderFlash;
	public function p_SetShader2D():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1241>";
		if(!((m_shader2d_)!=null)){
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1246>";
		m_shader2d_=((c_TShader.m_DefaultShader()) as c_TShaderFlash);
		popErr();
	}
	public function p_DrawClearQuad(t_cam:c_TCamera,t_r:Number,t_g:Number,t_b:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1210>";
		if(m_fastQuad==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1211>";
			m_fastQuad=(bb_functions_CreateSprite(null));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1212>";
			m_fastQuad.p_RemoveFromRenderList();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1213>";
			m_fastQuad.p_ScaleEntity((c_TRender.m_width),(c_TRender.m_height),1.0,0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1214>";
			m_fastQuad.p_PositionEntity(0.0,0.0,1.99999,0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1215>";
			m_fastQuad.p_EntityFX(105);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1217>";
			dbg_object(m_fastQuad).m_classname="fastQuad";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1218>";
			((m_fastQuad) as c_IRenderUpdate).p_Update2(c_TRender.m_camera2D);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1221>";
		c_TRender.m_render.p_Reset();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1222>";
		this.p_SetShader2D();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1223>";
		m_fastQuad.p_EntityColorFloat(t_r,t_g,t_b,-1.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1225>";
		c_TRender.m_alpha_pass=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1226>";
		var t_wireframeIsEnabled:int=c_TRender.m_wireframe;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1227>";
		c_TRender.m_wireframe=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1230>";
		m_driver.context3d.setColorMask(true,true,true,true);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1231>";
		c_TRender.m_render.p_Render((m_fastQuad),c_TRender.m_camera2D);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1232>";
		m_driver.context3d.setColorMask(true,true,true,true);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1233>";
		c_TRender.m_wireframe=t_wireframeIsEnabled;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1234>";
		c_TRender.m_render.p_Finish();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1235>";
		c_TRender.m_render.p_Reset();
		popErr();
	}
	public override function p_UpdateCamera(t_cam:c_TCamera):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1129>";
		if(t_cam.p_Hidden()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1129>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1133>";
		m_driver.SetScissorRectangle_(dbg_object(t_cam).m_vx,-(dbg_object(t_cam).m_vy-c_TRender.m_height+dbg_object(t_cam).m_vheight),dbg_object(t_cam).m_vwidth,dbg_object(t_cam).m_vheight);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1140>";
		if(dbg_object(t_cam).m_cls_color==true && dbg_object(t_cam).m_cls_zbuffer==true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1142>";
			m_driver.context3d.clear(dbg_object(t_cam).m_cls_r,dbg_object(t_cam).m_cls_g,dbg_object(t_cam).m_cls_b,0.0,1.0,0,Context3DClearMask.DEPTH);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1143>";
			this.p_DrawClearQuad(t_cam,dbg_object(t_cam).m_cls_r,dbg_object(t_cam).m_cls_g,dbg_object(t_cam).m_cls_b);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1152>";
			if(dbg_object(t_cam).m_cls_color==true){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1154>";
				this.p_DrawClearQuad(t_cam,dbg_object(t_cam).m_cls_r,dbg_object(t_cam).m_cls_g,dbg_object(t_cam).m_cls_b);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1155>";
				if(dbg_object(t_cam).m_cls_zbuffer==true){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1157>";
					m_driver.context3d.clear(dbg_object(t_cam).m_cls_r,dbg_object(t_cam).m_cls_g,dbg_object(t_cam).m_cls_b,0.0,1.0,0,Context3DClearMask.DEPTH);
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1163>";
		if(dbg_object(t_cam).m_fog_mode>0){
		}
		popErr();
		return 0;
	}
	public override function p_ClearErrors():int{
		pushErr();
		popErr();
		return 0;
	}
}
class c_BlankShader extends Object implements c_IShader2D{
	public function m_BlankShader_new():c_BlankShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<12>";
		popErr();
		return this;
	}
	public function p_SetShader2D():void{
		pushErr();
		popErr();
	}
}
class c_MojoEmulationDevice extends gxtkGraphics{
	internal static var m__device:c_MojoEmulationDevice;
	internal static var m__olddevice:gxtkGraphics;
	public function m_MojoEmulationDevice_new():c_MojoEmulationDevice{
		pushErr();
		popErr();
		return this;
	}
	internal static var m__quadCache:c_QuadCache;
	internal var m_mesh:c_TMesh=null;
	internal var m_layer:int=0;
	internal var m_solid:Array=new_object_array(512);
	public function p_NewLayer():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<129>";
		if(m_mesh==null){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<131>";
		m_layer+=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<132>";
		if(m_layer>512){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<132>";
			m_layer=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<133>";
		if(!((dbg_array(m_solid,m_layer)[dbg_index])!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<133>";
			dbg_array(m_solid,m_layer)[dbg_index]=m_mesh.p_CreateSurface(null);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<133>";
			m_mesh.p_AddSurface(dbg_array(m_solid,m_layer)[dbg_index]);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<136>";
		dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_no_verts=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<137>";
		dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_no_tris=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<138>";
		dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_vbo_dyn=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<139>";
		dbg_object(dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_brush).m_fx=35;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<140>";
		dbg_object(dbg_object(m_mesh).m_brush).m_blend=0;
		popErr();
	}
	internal var m_lastBlend:int=-1;
	internal var m_lastSurface:c_MojoSurface=null;
	internal var m_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	public function p_Reset():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<146>";
		if(!((m_mesh)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<147>";
			m_mesh=bb_functions_CreateMesh(null);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<148>";
			dbg_object(m_mesh).m_entity_link.p_Remove();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<149>";
			m_mesh.p_EntityFX(67);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<151>";
			m_layer=-1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<152>";
			this.p_NewLayer();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<162>";
		dbg_object(m_mesh).m_no_surfs=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<163>";
		dbg_object(m_mesh).m_surf_list.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<164>";
		dbg_object(m_mesh).m_surf_list.p_AddLast2(dbg_array(m_solid,0)[dbg_index]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<166>";
		dbg_object(dbg_array(m_solid,0)[dbg_index]).m_no_verts=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<167>";
		dbg_object(dbg_array(m_solid,0)[dbg_index]).m_no_tris=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<169>";
		m_layer=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<170>";
		m_lastBlend=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<171>";
		m_lastSurface=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<173>";
		c_TRender.m_draw_list.p_AddLast3(m_mesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<175>";
		m_mat.p_LoadIdentity();
		popErr();
		return 0;
	}
	internal static var m_firstTimeRun:Boolean;
	internal var m_fontImage:c_Image=null;
	internal var m_fontFile:String="mojo_font.png";
	public function p_InitFont():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<102>";
		if(((m_fontImage)!=null) && m_fontImage.p_Width()>0){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<106>";
		m_fontImage=bb_graphics_LoadImage(m_fontFile,96,2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<108>";
		if(((m_fontImage)!=null) && m_fontImage.p_Width()>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<109>";
			bb_graphics_SetFont(m_fontImage,32);
		}
		popErr();
	}
	public static function m_SetDevice():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<73>";
		if(!((m__device)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<75>";
			m__olddevice=bb_graphics_GetGraphicsDevice();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<76>";
			m__device=(new c_MojoEmulationDevice).m_MojoEmulationDevice_new();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<77>";
			m__quadCache=(new c_QuadCache).m_QuadCache_new();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<80>";
			((c_TRender.m_render) as c_FlashMiniB3D).p_ForceFlashTransparency(m__olddevice);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<81>";
			((c_TRender.m_render) as c_FlashMiniB3D).p_ForceFlashTransparency(m__device);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<86>";
		m__device.p_Reset();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<87>";
		bb_graphics_SetGraphicsDevice(m__device);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<88>";
		bb_graphics_BeginRender();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<91>";
		if(m_firstTimeRun){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<92>";
			m__device.p_InitFont();
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<94>";
			bb_functions_PreLoadPixmap2(dbg_object(m__device).m_fontFile);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<96>";
		m_firstTimeRun=true;
		popErr();
	}
	public override function Width():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<191>";
		popErr();
		return c_TRender.m_width;
	}
	public override function Height():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<195>";
		popErr();
		return c_TRender.m_height;
	}
	public override function LoadSurface(t_path:String):gxtkSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<200>";
		var t_msurf:c_MojoSurface=c_MojoSurface.m_PreLoad(t_path,m_mesh,m__device);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<202>";
		var t_:gxtkSurface=((t_msurf) as gxtkSurface);
		popErr();
		return t_;
	}
	public override function CreateSurface(t_width:int,t_height:int):gxtkSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<206>";
		var t_msurf:c_MojoSurface=c_MojoSurface.m_Create("");
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<208>";
		var t_:gxtkSurface=((t_msurf) as gxtkSurface);
		popErr();
		return t_;
	}
	public override function WritePixels2(t_surface:gxtkSurface,t_pixels:Array,t_x:int,t_y:int,t_width:int,t_height:int,t_offset:int,t_pitch:int):int{
		pushErr();
		popErr();
		return 0;
	}
	public override function Cls(t_r:Number,t_g:Number,t_b:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<239>";
		c_TRender.m_camera2D.p_CameraClsColor(t_r,t_g,t_b);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<240>";
		c_TRender.m_camera2D.p_CameraClsMode(true,false);
		popErr();
		return 0;
	}
	internal var m_colora:Number=1.0;
	public override function SetAlpha(t_alpha:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<244>";
		m_colora=t_alpha;
		popErr();
		return 0;
	}
	internal var m_colorr:int=0;
	internal var m_colorg:int=0;
	internal var m_colorb:int=0;
	public override function SetColor(t_r:Number,t_g:Number,t_b:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<248>";
		m_colorr=((t_r)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<248>";
		m_colorg=((t_g)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<248>";
		m_colorb=((t_b)|0);
		popErr();
		return 0;
	}
	public override function SetMatrix(t_ix:Number,t_iy:Number,t_jx:Number,t_jy:Number,t_tx:Number,t_ty:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<252>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,0)[dbg_index],0)[dbg_index]=t_ix;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<253>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,1)[dbg_index],0)[dbg_index]=t_iy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<254>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,0)[dbg_index],1)[dbg_index]=t_jx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<255>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,1)[dbg_index],1)[dbg_index]=t_jy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<256>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index]=t_tx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<257>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index]=-t_ty;
		popErr();
		return 0;
	}
	public override function SetScissor(t_x:int,t_y:int,t_width:int,t_height:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<261>";
		c_TRender.m_camera2D.p_CameraScissor(t_x,t_y,t_width,t_height);
		popErr();
		return 0;
	}
	public override function SetBlend(t_blend:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<266>";
		if(t_blend!=m_lastBlend){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<266>";
			this.p_NewLayer();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<268>";
		if(t_blend==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<269>";
			dbg_object(dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_brush).m_blend=3;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<270>";
			if(t_blend==1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<271>";
				dbg_object(dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_brush).m_blend=4;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<273>";
				dbg_object(dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_brush).m_blend=1;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<279>";
		m_lastBlend=t_blend;
		popErr();
		return 0;
	}
	public function p_Check(t_s:c_MojoSurface):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<181>";
		if(t_s!=m_lastSurface){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<182>";
			this.p_NewLayer();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<183>";
			m_lastSurface=t_s;
		}
		popErr();
		return 0;
	}
	internal var m_zdepth:Number=1.99999;
	public function p_AddQuad(t_s:c_TSurface,t_x:Number,t_y:Number,t_w:Number,t_h:Number,t_u:Number,t_v:Number,t_uw:Number,t_vh:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<460>";
		var t_p0:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<460>";
		var t_p1:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<460>";
		var t_p2:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<460>";
		var t_p3:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<461>";
		var t_r:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<461>";
		var t_g:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<461>";
		var t_b:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<463>";
		t_p0=bb_mojographics_Transform2D(m_mat,t_x,-t_h-t_y,m_zdepth);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<464>";
		t_p1=bb_mojographics_Transform2D(m_mat,t_x,-t_y,m_zdepth);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<465>";
		t_p2=bb_mojographics_Transform2D(m_mat,t_x+t_w,-t_y,m_zdepth);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<466>";
		t_p3=bb_mojographics_Transform2D(m_mat,t_x+t_w,-t_h-t_y,m_zdepth);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<467>";
		t_r=(m_colorr)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<468>";
		t_g=(m_colorg)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<469>";
		t_b=(m_colorb)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<475>";
		m__quadCache.p_AddCache(t_s,[dbg_array(t_p0,0)[dbg_index],dbg_array(t_p0,1)[dbg_index],-dbg_array(t_p0,2)[dbg_index],0.0,1.0,1.0,1.0,0.0,t_r,t_g,t_b,m_colora,t_u,t_vh,t_u,t_vh,dbg_array(t_p1,0)[dbg_index],dbg_array(t_p1,1)[dbg_index],-dbg_array(t_p1,2)[dbg_index],0.0,1.0,1.0,1.0,0.0,t_r,t_g,t_b,m_colora,t_u,t_v,t_u,t_v,dbg_array(t_p2,0)[dbg_index],dbg_array(t_p2,1)[dbg_index],-dbg_array(t_p2,2)[dbg_index],0.0,1.0,1.0,1.0,0.0,t_r,t_g,t_b,m_colora,t_uw,t_v,t_uw,t_v,dbg_array(t_p3,0)[dbg_index],dbg_array(t_p3,1)[dbg_index],-dbg_array(t_p3,2)[dbg_index],0.0,1.0,1.0,1.0,0.0,t_r,t_g,t_b,m_colora,t_uw,t_vh,t_uw,t_vh]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<482>";
		dbg_object(t_s).m_reset_vbo=-1;
		popErr();
	}
	public override function DrawPoint(t_x:Number,t_y:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<284>";
		this.p_Check(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<285>";
		this.p_AddQuad(dbg_array(m_solid,m_layer)[dbg_index],t_x,t_y,1.0,1.0,0.0,0.0,1.0,1.0);
		popErr();
		return 0;
	}
	public override function DrawRect(t_x:Number,t_y:Number,t_w:Number,t_h:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<291>";
		this.p_Check(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<292>";
		this.p_AddQuad(dbg_array(m_solid,m_layer)[dbg_index],t_x,t_y,t_w,t_h,0.0,0.0,1.0,1.0);
		popErr();
		return 0;
	}
	public override function DrawLine(t_x1:Number,t_y1:Number,t_x2:Number,t_y2:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<298>";
		this.p_Check(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<300>";
		var t_p0:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<301>";
		t_p0=bb_mojographics_Transform2D(m_mat,t_x1,-t_y1,m_zdepth);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<302>";
		t_x1=dbg_array(t_p0,0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<302>";
		t_y1=dbg_array(t_p0,1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<303>";
		t_p0=bb_mojographics_Transform2D(m_mat,t_x2,-t_y2,m_zdepth);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<304>";
		t_x2=dbg_array(t_p0,0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<304>";
		t_y2=dbg_array(t_p0,1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<306>";
		var t_px:Number=t_y1-t_y2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<307>";
		var t_py:Number=-(t_x1-t_x2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<308>";
		var t_d:Number=1.0/Math.sqrt(t_px*t_px+t_py*t_py);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<310>";
		t_px=t_px*t_d;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<311>";
		t_py=t_py*t_d;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<313>";
		var t_v0:int=dbg_array(m_solid,m_layer)[dbg_index].p_AddVertex(t_x2,t_y2,m_zdepth,0.0,1.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<314>";
		var t_v1:int=dbg_array(m_solid,m_layer)[dbg_index].p_AddVertex(t_x1,t_y1,m_zdepth,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<315>";
		var t_v2:int=dbg_array(m_solid,m_layer)[dbg_index].p_AddVertex(t_x1+t_px,t_y1+t_py,m_zdepth,1.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<316>";
		dbg_array(m_solid,m_layer)[dbg_index].p_AddTriangle(t_v0,t_v1,t_v2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<318>";
		var t_v3:int=dbg_array(m_solid,m_layer)[dbg_index].p_AddVertex(t_x2+t_px,t_y2+t_py,m_zdepth,1.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<319>";
		dbg_array(m_solid,m_layer)[dbg_index].p_AddTriangle(t_v0,t_v2,t_v3);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<321>";
		dbg_array(m_solid,m_layer)[dbg_index].p_VertexColor(t_v0,(m_colorr),(m_colorg),(m_colorb),m_colora);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<322>";
		dbg_array(m_solid,m_layer)[dbg_index].p_VertexColor(t_v1,(m_colorr),(m_colorg),(m_colorb),m_colora);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<323>";
		dbg_array(m_solid,m_layer)[dbg_index].p_VertexColor(t_v2,(m_colorr),(m_colorg),(m_colorb),m_colora);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<324>";
		dbg_array(m_solid,m_layer)[dbg_index].p_VertexColor(t_v3,(m_colorr),(m_colorg),(m_colorb),m_colora);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<327>";
		dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_reset_vbo=-1;
		popErr();
		return 0;
	}
	public override function DrawPoly(t_verts:Array):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<367>";
		this.p_Check(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<369>";
		var t_p0:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<369>";
		var t_p1:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<369>";
		var t_p2:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<369>";
		var t_p3:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<370>";
		var t_r:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<370>";
		var t_g:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<370>";
		var t_b:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<372>";
		var t_tris:Array=new_number_array((t_verts.length-7)*6*3);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<373>";
		var t_t:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<373>";
		var t_vt:int=dbg_object(dbg_array(m_solid,m_layer)[dbg_index]).m_no_verts;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<377>";
		t_r=(m_colorr)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<378>";
		t_g=(m_colorg)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<379>";
		t_b=(m_colorb)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<381>";
		for(var t_i:int=0;t_i<=t_verts.length-7;t_i=t_i+6){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<382>";
			t_p0=bb_mojographics_Transform2D(m_mat,dbg_array(t_verts,t_i+0)[dbg_index],-dbg_array(t_verts,t_i+1)[dbg_index],m_zdepth);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<383>";
			t_p1=bb_mojographics_Transform2D(m_mat,dbg_array(t_verts,t_i+2)[dbg_index],-dbg_array(t_verts,t_i+3)[dbg_index],m_zdepth);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<384>";
			t_p2=bb_mojographics_Transform2D(m_mat,dbg_array(t_verts,t_i+4)[dbg_index],-dbg_array(t_verts,t_i+5)[dbg_index],m_zdepth);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<387>";
			t_vt=t_vt+3;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<403>";
			dbg_array(m_solid,m_layer)[dbg_index].p_AddVertex2([dbg_array(t_p0,0)[dbg_index],dbg_array(t_p0,1)[dbg_index],-dbg_array(t_p0,2)[dbg_index],0.0,1.0,1.0,1.0,0.0,(m_colorr)*0.0039215686274509803,(m_colorg)*0.0039215686274509803,(m_colorb)*0.0039215686274509803,m_colora,0.0,0.0,0.0,0.0,dbg_array(t_p1,0)[dbg_index],dbg_array(t_p1,1)[dbg_index],-dbg_array(t_p1,2)[dbg_index],0.0,1.0,1.0,1.0,0.0,(m_colorr)*0.0039215686274509803,(m_colorg)*0.0039215686274509803,(m_colorb)*0.0039215686274509803,m_colora,0.0,0.0,0.0,0.0,dbg_array(t_p2,0)[dbg_index],dbg_array(t_p2,1)[dbg_index],-dbg_array(t_p2,2)[dbg_index],0.0,1.0,1.0,1.0,0.0,(m_colorr)*0.0039215686274509803,(m_colorg)*0.0039215686274509803,(m_colorb)*0.0039215686274509803,m_colora,0.0,0.0,0.0,0.0],-1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<409>";
			dbg_array(t_tris,t_t)[dbg_index]=t_vt-3;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<409>";
			dbg_array(t_tris,t_t+1)[dbg_index]=t_vt-2;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<409>";
			dbg_array(t_tris,t_t+2)[dbg_index]=t_vt-1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<410>";
			t_t=t_t+3;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<416>";
		dbg_array(m_solid,m_layer)[dbg_index].p_AddTriangle2(t_tris,-1);
		popErr();
		return 0;
	}
	public override function DrawOval(t_x:Number,t_y:Number,t_w:Number,t_h:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<333>";
		this.p_Check(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<335>";
		if(t_w<0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<335>";
			t_w=-t_w;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<336>";
		if(t_h<0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<336>";
			t_h=-t_h;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<337>";
		var t_seg:int=(((t_w+t_h)*0.2)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<338>";
		if(t_seg<14){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<338>";
			t_seg=14;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<340>";
		var t_deg:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<340>";
		var t_deginc:Number=360.0/(t_seg);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<341>";
		var t_verts:Array=new_number_array(t_seg*6+1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<343>";
		for(var t_i:int=0;t_i<=t_verts.length-7;t_i=t_i+6){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<345>";
			dbg_array(t_verts,t_i+0)[dbg_index]=t_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<346>";
			dbg_array(t_verts,t_i+1)[dbg_index]=t_y;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<347>";
			dbg_array(t_verts,t_i+2)[dbg_index]=t_x+t_w*Math.cos((t_deg)*D2R);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<348>";
			dbg_array(t_verts,t_i+3)[dbg_index]=t_y+t_h*Math.sin((t_deg)*D2R);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<349>";
			dbg_array(t_verts,t_i+4)[dbg_index]=t_x+t_w*Math.cos((t_deg+t_deginc)*D2R);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<350>";
			dbg_array(t_verts,t_i+5)[dbg_index]=t_y+t_h*Math.sin((t_deg+t_deginc)*D2R);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<352>";
			t_deg+=t_deginc;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<356>";
		this.DrawPoly(t_verts);
		popErr();
		return 0;
	}
	public override function DrawSurface2(t_surface:gxtkSurface,t_x:Number,t_y:Number,t_srcx:int,t_srcy:int,t_srcw:int,t_srch:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<427>";
		var t_s:c_MojoSurface=((t_surface) as c_MojoSurface);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<428>";
		if(!((t_s)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<428>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<430>";
		this.p_Check(t_s);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<432>";
		if((dbg_object(t_s).m_tex)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<432>";
			dbg_array(m_solid,m_layer)[dbg_index].p_PaintSurface2(dbg_object(t_s).m_tex,0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<435>";
		var t_xstep:Number=dbg_object(t_s).m_xstep;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<436>";
		var t_ystep:Number=dbg_object(t_s).m_ystep;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<437>";
		var t_upos:Number=(t_srcx)*t_xstep;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<438>";
		var t_vpos:Number=(t_srcy)*t_ystep;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<440>";
		this.p_AddQuad(dbg_array(m_solid,m_layer)[dbg_index],t_x,t_y,(t_srcw),(t_srch),t_upos,t_vpos,t_upos+t_xstep*(t_srcw),t_vpos+t_ystep*(t_srch));
		popErr();
		return 0;
	}
	public override function DrawSurface(t_surface:gxtkSurface,t_x:Number,t_y:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<421>";
		this.DrawSurface2(t_surface,t_x,t_y,0,0,t_surface.Width(),t_surface.Height());
		popErr();
		return 0;
	}
	public override function ReadPixels(t_pixels:Array,t_x:int,t_y:int,t_width:int,t_height:int,t_offset:int,t_pitch:int):int{
		pushErr();
		popErr();
		return 0;
	}
}
internal function bb_graphics_GetGraphicsDevice():gxtkGraphics{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/graphics.monkey<67>";
	popErr();
	return bb_graphics_device;
}
class c_QuadCache extends Object{
	public function m_QuadCache_new():c_QuadCache{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<598>";
		popErr();
		return this;
	}
	internal var m_q_num:int=0;
	internal var m_q_cache:Array=new_number_array(1280);
	internal var m_q_surf:c_TSurface=null;
	internal var m_q_tri:Array=new_number_array(128);
	public function p_FlushCache():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<627>";
		if(m_q_num==0){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<629>";
		var t_n:int=m_q_num;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<630>";
		var t_v4:int=m_q_surf.p_AddVertex2(m_q_cache,m_q_num*64);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<632>";
		t_v4=t_v4+1-m_q_num*4;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<635>";
		var t_k:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<636>";
		for(var t_j:int=0;t_j<=t_n-1;t_j=t_j+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<637>";
			dbg_array(m_q_tri,t_k+0)[dbg_index]=t_v4;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<637>";
			dbg_array(m_q_tri,t_k+1)[dbg_index]=t_v4+1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<637>";
			dbg_array(m_q_tri,t_k+2)[dbg_index]=t_v4+2;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<638>";
			dbg_array(m_q_tri,t_k+3)[dbg_index]=t_v4;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<638>";
			dbg_array(m_q_tri,t_k+4)[dbg_index]=t_v4+2;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<638>";
			dbg_array(m_q_tri,t_k+5)[dbg_index]=t_v4+3;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<640>";
			t_k=t_k+6;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<641>";
			t_v4=t_v4+4;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<643>";
		m_q_surf.p_AddTriangle2(m_q_tri,m_q_num*6);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<645>";
		m_q_num=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<646>";
		m_q_surf=null;
		popErr();
	}
	public function p_AddCache(t_s:c_TSurface,t_v:Array):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<609>";
		if(t_s!=m_q_surf || m_q_num>19){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<611>";
			this.p_FlushCache();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<614>";
		m_q_surf=t_s;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<616>";
		var t_offset:int=m_q_num*64;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<617>";
		for(var t_i:int=0;t_i<=63;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<618>";
			dbg_array(m_q_cache,t_offset+t_i)[dbg_index]=dbg_array(t_v,t_i)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<621>";
		m_q_num+=1;
		popErr();
	}
}
class c_TEntity extends Object{
	internal var m_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal var m_loc_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	public function m_TEntity_new():c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<133>";
		m_mat.p_LoadIdentity();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<134>";
		m_loc_mat.p_LoadIdentity();
		popErr();
		return this;
	}
	internal var m_classname:String="";
	internal var m_parent:c_TEntity=null;
	internal var m_px:Number=.0;
	internal var m_py:Number=.0;
	internal var m_pz:Number=.0;
	internal var m_rx:Number=.0;
	internal var m_ry:Number=.0;
	internal var m_rz:Number=.0;
	internal var m_sx:Number=1.0;
	internal var m_sy:Number=1.0;
	internal var m_sz:Number=1.0;
	internal var m_gsx:Number=1.0;
	internal var m_gsy:Number=1.0;
	internal var m_gsz:Number=1.0;
	internal var m_collision:c_TCollision=(new c_TCollision).m_TCollision_new();
	public function p_UpdateMat(t_load_identity:Boolean):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2110>";
		if(t_load_identity==true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2111>";
			m_mat.p_LoadIdentity();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2114>";
		if(t_load_identity==false && ((m_parent)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2116>";
			m_mat.p_Overwrite(dbg_object(m_parent).m_mat);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2119>";
		m_mat.p_Translate(m_px,m_py,m_pz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2120>";
		m_mat.p_Rotate(m_rx,m_ry,m_rz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2121>";
		m_mat.p_Scale(m_sx,m_sy,m_sz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2127>";
		if(t_load_identity){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2127>";
			m_loc_mat.p_Overwrite(m_mat);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2129>";
		if((m_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2130>";
			m_gsx=dbg_object(m_parent).m_gsx*m_sx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2130>";
			m_gsy=dbg_object(m_parent).m_gsy*m_sy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2130>";
			m_gsz=dbg_object(m_parent).m_gsz*m_sz;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2132>";
			m_gsx=m_sx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2132>";
			m_gsy=m_sy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2132>";
			m_gsz=m_sz;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2135>";
		dbg_object(m_collision).m_updated_shape=false;
		popErr();
	}
	internal var m_child_list:c_EntityList=(new c_EntityList).m_EntityList_new();
	internal var m_parent_link:c_Node2=null;
	public function p_AddParent(t_parent_ent:c_TEntity):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1212>";
		m_parent=t_parent_ent;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1215>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1217>";
			m_mat.p_Overwrite(dbg_object(m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1218>";
			this.p_UpdateMat(false);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1220>";
			m_parent_link=dbg_object(m_parent).m_child_list.p_AddLast(this);
		}
		popErr();
		return 0;
	}
	internal static var m_entity_list:c_EntityList;
	internal var m_order:int=0;
	internal var m_entity_link:c_Node2=null;
	internal var m_brush:c_TBrush=(new c_TBrush).m_TBrush_new();
	public function p_EntityFX(t_fx_no:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1002>";
		dbg_object(m_brush).m_fx=t_fx_no;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1003>";
		popErr();
		return this;
	}
	public function p_EntityFX2():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1008>";
		popErr();
		return dbg_object(m_brush).m_fx;
	}
	internal var m_name:String="";
	public function p_X():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<269>";
		popErr();
		return dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index];
	}
	public function p_X2(t_xx:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<278>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index]=t_xx;
		popErr();
	}
	public function p_Y():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<272>";
		popErr();
		return dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index];
	}
	public function p_Y2(t_yy:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<281>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index]=t_yy;
		popErr();
	}
	public function p_Z():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<275>";
		var t_:Number=-dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],2)[dbg_index];
		popErr();
		return t_;
	}
	public function p_Z2(t_zz:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<284>";
		dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],2)[dbg_index]=-t_zz;
		popErr();
	}
	internal static var m_temp_mat:c_Matrix;
	public function p_UpdateMatTrans(t_load_identity:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2145>";
		if(t_load_identity==false && ((m_parent)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2147>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,0)[dbg_index],0)[dbg_index]*m_px+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,1)[dbg_index],0)[dbg_index]*m_py+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,2)[dbg_index],0)[dbg_index]*m_pz+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,3)[dbg_index],0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2148>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,0)[dbg_index],1)[dbg_index]*m_px+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,1)[dbg_index],1)[dbg_index]*m_py+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,2)[dbg_index],1)[dbg_index]*m_pz+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,3)[dbg_index],1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2149>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,0)[dbg_index],2)[dbg_index]*m_px+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,1)[dbg_index],2)[dbg_index]*m_py+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,2)[dbg_index],2)[dbg_index]*m_pz+dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,3)[dbg_index],2)[dbg_index];
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2152>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index]=m_px;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2153>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index]=m_py;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2154>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],2)[dbg_index]=m_pz;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2158>";
		if(t_load_identity){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2158>";
			m_loc_mat.p_Overwrite(m_mat);
		}
		popErr();
		return 0;
	}
	public static function m_UpdateChildren(t_ent_p:c_TEntity,t_type:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2194>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2194>";
		var t_:c_Enumerator2=dbg_object(t_ent_p).m_child_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2194>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2194>";
			var t_ent_c:c_TEntity=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2197>";
			if(((t_ent_c) as c_TBone)==null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2200>";
				if(t_type==0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2201>";
					dbg_object(t_ent_c).m_mat.p_Overwrite(dbg_object(t_ent_p).m_mat);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2202>";
					t_ent_c.p_UpdateMat(false);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2203>";
					if(t_type==1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2204>";
						t_ent_c.p_UpdateMatTrans(false);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2206>";
						dbg_object(t_ent_c).m_mat.p_Overwrite(dbg_object(t_ent_p).m_mat);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2207>";
						t_ent_c.p_UpdateMat(false);
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2211>";
				m_UpdateChildren(t_ent_c,t_type);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2215>";
				((t_ent_c) as c_TBone).p_UpdateMatrix(dbg_object(t_ent_c).m_loc_mat);
			}
		}
		popErr();
		return 0;
	}
	public function p_PositionEntity(t_x:Number,t_y:Number,t_z:Number,t_glob:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<304>";
		t_z=-t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<308>";
		if(t_glob==1 && m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<310>";
			m_temp_mat=dbg_object(m_parent).m_mat.p_Copy().p_Inverse();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<312>";
			var t_psx:Number=dbg_object(m_parent).m_gsx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<313>";
			var t_psy:Number=dbg_object(m_parent).m_gsy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<314>";
			var t_psz:Number=dbg_object(m_parent).m_gsz;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<317>";
			var t_pos:Array=m_temp_mat.p_TransformPoint(t_x,t_y,t_z,1.0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<319>";
			t_x=dbg_array(t_pos,0)[dbg_index]/(t_psx*t_psx);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<320>";
			t_y=dbg_array(t_pos,1)[dbg_index]/(t_psy*t_psy);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<321>";
			t_z=dbg_array(t_pos,2)[dbg_index]/(t_psz*t_psz);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<325>";
		if(((this) as c_TBone)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<325>";
			((this) as c_TBone).p_PositionBone(t_x,t_y,t_z,t_glob);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<325>";
			popErr();
			return this;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<327>";
		m_px=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<328>";
		m_py=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<329>";
		m_pz=t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<331>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<335>";
			this.p_UpdateMatTrans(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<339>";
			this.p_UpdateMatTrans(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<342>";
		if(m_child_list.p_IsEmpty()!=true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<342>";
			m_UpdateChildren(this,1);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<344>";
		popErr();
		return this;
	}
	public function p_PositionEntity2(t_e:c_TEntity):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<297>";
		this.p_PositionEntity(t_e.p_X(),t_e.p_Y(),t_e.p_Z(),1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<298>";
		popErr();
		return this;
	}
	internal var m_anim:int=0;
	public function p_EntityShininess(t_s:Number):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<915>";
		dbg_object(m_brush).m_shine=t_s;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<916>";
		popErr();
		return this;
	}
	public function p_EntityTexture(t_texture:c_TTexture,t_frame:int,t_index:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<922>";
		dbg_array(dbg_object(m_brush).m_tex,t_index)[dbg_index]=t_texture;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<924>";
		if(t_index+1>dbg_object(m_brush).m_no_texs){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<924>";
			dbg_object(m_brush).m_no_texs=t_index+1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<926>";
		if(t_frame<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<926>";
			t_frame=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<927>";
		if(t_frame>dbg_object(t_texture).m_no_frames-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<927>";
			t_frame=dbg_object(t_texture).m_no_frames-1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<928>";
		dbg_object(dbg_array(dbg_object(m_brush).m_tex,t_index)[dbg_index]).m_tex_frame=t_frame;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<930>";
		if(t_frame>0 && dbg_object(t_texture).m_no_frames>1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<932>";
			var t_x:int=t_frame % dbg_object(t_texture).m_frame_xstep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<933>";
			var t_y:int=((t_frame/dbg_object(t_texture).m_frame_ystep)|0) % dbg_object(t_texture).m_frame_ystep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<934>";
			dbg_object(dbg_array(dbg_object(m_brush).m_tex,t_index)[dbg_index]).m_u_pos=(t_x)*dbg_object(t_texture).m_frame_ustep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<935>";
			dbg_object(dbg_array(dbg_object(m_brush).m_tex,t_index)[dbg_index]).m_v_pos=(t_y)*dbg_object(t_texture).m_frame_vstep;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<938>";
		popErr();
		return this;
	}
	internal var m_hide:Boolean=false;
	public function p_HideEntity():c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1116>";
		m_hide=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1117>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1117>";
		var t_:c_Enumerator2=m_child_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1117>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1117>";
			var t_ent:c_TEntity=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1118>";
			t_ent.p_HideEntity();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1121>";
		popErr();
		return this;
	}
	public function p_MoveEntity(t_mx:Number,t_my:Number,t_mz:Number):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<349>";
		t_mz=-t_mz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<351>";
		var t_n:Array=[];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<353>";
		t_n=m_mat.p_TransformPoint(t_mx/m_gsx,t_my/m_gsy,t_mz/m_gsz,1.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<354>";
		this.p_PositionEntity(dbg_array(t_n,0)[dbg_index],dbg_array(t_n,1)[dbg_index],-dbg_array(t_n,2)[dbg_index],1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<356>";
		popErr();
		return this;
	}
	public function p_UpdateMatRot(t_load_identity:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2164>";
		if(t_load_identity==false && ((m_parent)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2166>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,0)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,0)[dbg_index],0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2166>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,0)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,0)[dbg_index],1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2166>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,0)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,0)[dbg_index],2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2167>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,1)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,1)[dbg_index],0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2167>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,1)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,1)[dbg_index],1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2167>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,1)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,1)[dbg_index],2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2168>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,2)[dbg_index],0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2168>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,2)[dbg_index],1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2168>";
			dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(dbg_object(m_parent).m_mat).m_grid,2)[dbg_index],2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2170>";
			m_mat.p_Rotate(m_rx,m_ry,m_rz);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2171>";
			m_mat.p_Scale(m_sx,m_sy,m_sz);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2173>";
			m_mat.p_FastRotateScale(m_rx,m_ry,m_rz,m_sx,m_sy,m_sz);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2176>";
		if((m_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2177>";
			m_gsx=dbg_object(m_parent).m_gsx*m_sx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2177>";
			m_gsy=dbg_object(m_parent).m_gsy*m_sy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2177>";
			m_gsz=dbg_object(m_parent).m_gsz*m_sz;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2179>";
			m_gsx=m_sx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2179>";
			m_gsy=m_sy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2179>";
			m_gsz=m_sz;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2182>";
		if(t_load_identity){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2182>";
			m_loc_mat.p_Overwrite(m_mat);
		}
		popErr();
		return 0;
	}
	public function p_TurnEntity(t_x:Number,t_y:Number,t_z:Number,t_glob:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<484>";
		if(t_glob==1 && m_parent!=null){
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<488>";
		m_rx=m_rx+-t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<489>";
		m_ry=m_ry+t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<490>";
		m_rz=m_rz+t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<493>";
		if(((this) as c_TBone)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<493>";
			((this) as c_TBone).p_RotateBone(m_rx,m_ry,m_rz,t_glob);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<493>";
			popErr();
			return this;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<496>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<500>";
			this.p_UpdateMatRot(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<504>";
			this.p_UpdateMatRot(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<507>";
		if(m_child_list.p_IsEmpty()!=true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<507>";
			m_UpdateChildren(this,0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<508>";
		popErr();
		return this;
	}
	public function p_EntityX(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1239>";
		if(t_glob==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1241>";
			popErr();
			return m_px;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1245>";
			popErr();
			return dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index];
		}
		return 0;
	}
	public function p_EntityY(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1253>";
		if(t_glob==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1255>";
			popErr();
			return m_py;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1259>";
			popErr();
			return dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index];
		}
		return 0;
	}
	public function p_EntityZ(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1267>";
		if(t_glob==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1269>";
			var t_:Number=-m_pz;
			popErr();
			return t_;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1273>";
			var t_2:Number=-dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],2)[dbg_index];
			popErr();
			return t_2;
		}
		return 0;
	}
	public function p_EntityPitch(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1281>";
		if(t_glob==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1283>";
			var t_:Number=-m_rx;
			popErr();
			return t_;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1287>";
			var t_ang:Number=(Math.atan2(dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],1)[dbg_index],Math.sqrt(dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],2)[dbg_index]))*R2D);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1288>";
			if(t_ang<=0.0001 && t_ang>=-0.0001){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1288>";
				t_ang=0.0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1290>";
			popErr();
			return t_ang;
		}
		return 0;
	}
	public function p_EntityYaw(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1298>";
		if(t_glob==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1300>";
			popErr();
			return m_ry;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1304>";
			var t_a:Number=dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1305>";
			var t_b:Number=dbg_array(dbg_array(dbg_object(m_mat).m_grid,2)[dbg_index],2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1306>";
			if(t_a<=0.0001 && t_a>=-0.0001){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1306>";
				t_a=0.0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1307>";
			if(t_b<=0.0001 && t_b>=-0.0001){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1307>";
				t_b=0.0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1308>";
			var t_:Number=(Math.atan2(t_a,t_b)*R2D);
			popErr();
			return t_;
		}
		return 0;
	}
	public function p_EntityRoll(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1316>";
		if(t_glob==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1318>";
			popErr();
			return m_rz;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1322>";
			var t_a:Number=dbg_array(dbg_array(dbg_object(m_mat).m_grid,0)[dbg_index],1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1323>";
			var t_b:Number=dbg_array(dbg_array(dbg_object(m_mat).m_grid,1)[dbg_index],1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1324>";
			if(t_a<=0.0001 && t_a>=-0.0001){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1324>";
				t_a=0.0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1325>";
			if(t_b<=0.0001 && t_b>=-0.0001){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1325>";
				t_b=0.0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1326>";
			var t_:Number=(Math.atan2(t_a,t_b)*R2D);
			popErr();
			return t_;
		}
		return 0;
	}
	public function p_RotateEntity(t_x:Number,t_y:Number,t_z:Number,t_glob:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<449>";
		m_rx=-t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<450>";
		m_ry=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<451>";
		m_rz=t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<454>";
		if(t_glob==1 && m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<456>";
			m_rx=m_rx+m_parent.p_EntityPitch(1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<457>";
			m_ry=m_ry-m_parent.p_EntityYaw(1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<458>";
			m_rz=m_rz-m_parent.p_EntityRoll(1);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<463>";
		if(((this) as c_TBone)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<463>";
			((this) as c_TBone).p_RotateBone(m_rx,m_ry,m_rz,t_glob);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<463>";
			popErr();
			return this;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<465>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<469>";
			this.p_UpdateMatRot(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<473>";
			this.p_UpdateMatRot(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<476>";
		if(m_child_list.p_IsEmpty()!=true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<476>";
			m_UpdateChildren(this,0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<477>";
		popErr();
		return this;
	}
	public function p_RotateEntity2(t_e:c_TEntity):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<443>";
		this.p_RotateEntity(dbg_object(t_e).m_rx,dbg_object(t_e).m_ry,dbg_object(t_e).m_rz,1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<444>";
		popErr();
		return this;
	}
	public function p_EntityScaleX(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1973>";
		if(t_glob==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1975>";
			if(m_parent!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1977>";
				var t_ent:c_TEntity=this;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1979>";
				var t_x:Number=m_sx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1981>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1983>";
					t_x=t_x*dbg_object(dbg_object(t_ent).m_parent).m_sx;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1985>";
					t_ent=dbg_object(t_ent).m_parent;
				}while(!(dbg_object(t_ent).m_parent==null));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1989>";
				popErr();
				return t_x;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1995>";
		popErr();
		return m_sx;
	}
	public function p_EntityScaleY(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2001>";
		if(t_glob==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2003>";
			if(m_parent!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2005>";
				var t_ent:c_TEntity=this;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2007>";
				var t_y:Number=m_sy;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2009>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2011>";
					t_y=t_y*dbg_object(dbg_object(t_ent).m_parent).m_sy;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2013>";
					t_ent=dbg_object(t_ent).m_parent;
				}while(!(dbg_object(t_ent).m_parent==null));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2017>";
				popErr();
				return t_y;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2023>";
		popErr();
		return m_sy;
	}
	public function p_EntityScaleZ(t_glob:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2029>";
		if(t_glob==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2031>";
			if(m_parent!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2033>";
				var t_ent:c_TEntity=this;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2035>";
				var t_z:Number=m_sz;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2037>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2039>";
					t_z=t_z*dbg_object(dbg_object(t_ent).m_parent).m_sz;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2041>";
					t_ent=dbg_object(t_ent).m_parent;
				}while(!(dbg_object(t_ent).m_parent==null));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2045>";
				popErr();
				return t_z;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2051>";
		popErr();
		return m_sz;
	}
	public function p_ScaleEntity(t_x:Number,t_y:Number,t_z:Number,t_glob:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<396>";
		m_sx=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<397>";
		m_sy=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<398>";
		m_sz=t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<401>";
		if(t_glob==1 && m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<403>";
			m_sx=m_sx/dbg_object(m_parent).m_gsx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<404>";
			m_sy=m_sy/dbg_object(m_parent).m_gsy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<405>";
			m_sz=m_sz/dbg_object(m_parent).m_gsz;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<410>";
		if(((this) as c_TBone)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<412>";
			((this) as c_TBone).p_ScaleBone(m_sx,m_sy,m_sz,t_glob);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<413>";
			popErr();
			return null;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<417>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<421>";
			this.p_UpdateMatRot(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<426>";
			this.p_UpdateMatRot(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<431>";
		if(m_child_list.p_IsEmpty()!=true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<431>";
			m_UpdateChildren(this,0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<432>";
		popErr();
		return this;
	}
	public function p_ScaleEntity2(t_e:c_TEntity):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<390>";
		this.p_ScaleEntity(t_e.p_EntityScaleX(0),t_e.p_EntityScaleY(0),t_e.p_EntityScaleZ(0),1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<391>";
		popErr();
		return this;
	}
	public function p_EntityParent(t_parent_ent:c_TEntity,t_glob:Boolean):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1146>";
		var t_gpx_:Number=this.p_EntityX(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1147>";
		var t_gpy_:Number=this.p_EntityY(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1148>";
		var t_gpz_:Number=this.p_EntityZ(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1150>";
		var t_grx_:Number=this.p_EntityPitch(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1151>";
		var t_gry_:Number=this.p_EntityYaw(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1152>";
		var t_grz_:Number=this.p_EntityRoll(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1159>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1160>";
			m_parent_link.p_Remove();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1161>";
			m_parent=null;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1166>";
		m_px=t_gpx_;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1167>";
		m_py=t_gpy_;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1168>";
		m_pz=-t_gpz_;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1169>";
		m_rx=-t_grx_;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1170>";
		m_ry=t_gry_;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1171>";
		m_rz=t_grz_;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1179>";
		if(t_parent_ent==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1180>";
			this.p_UpdateMat(true);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1181>";
			popErr();
			return null;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1186>";
		if(t_parent_ent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1188>";
			if(t_glob){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1190>";
				this.p_AddParent(t_parent_ent);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1193>";
				this.p_PositionEntity(t_gpx_,t_gpy_,t_gpz_,1);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1194>";
				this.p_RotateEntity(t_grx_,t_gry_,t_grz_,1);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1195>";
				this.p_ScaleEntity(m_gsx,m_gsy,m_gsz,1);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1199>";
				this.p_AddParent(t_parent_ent);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1206>";
		popErr();
		return this;
	}
	public function p_Hidden():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1127>";
		popErr();
		return m_hide;
	}
	internal var m_cull_radius:Number=.0;
	public function p_EntityRadius(t_x:Number,t_y:Number):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1652>";
		if(t_x==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1654>";
			var t_m:c_TMesh=((this) as c_TMesh);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1655>";
			if((t_m)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1656>";
				if(m_cull_radius==0.0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1656>";
					t_m.p_GetBounds(false);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1658>";
				var t_c:Number=.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1659>";
				t_c=bb_math_Max2(bb_math_Max2(bb_math_Abs2(dbg_object(t_m).m_max_x),bb_math_Abs2(dbg_object(t_m).m_max_y)),bb_math_Abs2(dbg_object(t_m).m_max_z));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1660>";
				t_c=bb_math_Max2(bb_math_Max2(bb_math_Max2(t_c,bb_math_Abs2(dbg_object(t_m).m_min_x)),bb_math_Abs2(dbg_object(t_m).m_min_y)),bb_math_Abs2(dbg_object(t_m).m_min_z));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1663>";
				t_x=t_c*1.4142135623;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1664>";
				t_x=Math.sqrt(t_x*t_x+t_c*t_c);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1666>";
				t_x=t_m.p_GetSphereBounds();
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1669>";
				t_x=1.0;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1674>";
		dbg_object(m_collision).m_radius_x=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1675>";
		if(t_y==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1675>";
			dbg_object(m_collision).m_radius_y=t_x;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1675>";
			dbg_object(m_collision).m_radius_y=t_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1678>";
		if(dbg_object(m_collision).m_box_w==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1679>";
			dbg_object(m_collision).m_box_x=-dbg_object(m_collision).m_radius_x*0.5;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1680>";
			dbg_object(m_collision).m_box_y=-dbg_object(m_collision).m_radius_x*0.5;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1681>";
			dbg_object(m_collision).m_box_z=-dbg_object(m_collision).m_radius_x*0.5;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1682>";
			dbg_object(m_collision).m_box_w=dbg_object(m_collision).m_radius_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1683>";
			dbg_object(m_collision).m_box_h=dbg_object(m_collision).m_radius_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1684>";
			dbg_object(m_collision).m_box_d=dbg_object(m_collision).m_radius_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1687>";
		dbg_object(m_collision).m_updated_shape=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1689>";
		popErr();
		return dbg_object(m_collision).m_radius_x;
	}
	public function p_EntityBox(t_x:Number,t_y:Number,t_z:Number,t_w:Number,t_h:Number,t_d:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1697>";
		if(t_x==0.0 && t_w==0.0 && t_d==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1700>";
			if(((this) as c_TMesh)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1701>";
				var t_m:c_TMesh=((this) as c_TMesh);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1702>";
				if(!((m_cull_radius)!=0.0)){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1702>";
					t_m.p_GetBounds(false);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1703>";
				t_x=dbg_object(t_m).m_min_x;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1704>";
				t_y=dbg_object(t_m).m_min_y;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1705>";
				t_z=dbg_object(t_m).m_min_z;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1706>";
				t_w=bb_math_Abs2(dbg_object(t_m).m_max_x-dbg_object(t_m).m_min_x);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1707>";
				t_h=bb_math_Abs2(dbg_object(t_m).m_max_y-dbg_object(t_m).m_min_y);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1708>";
				t_d=bb_math_Abs2(dbg_object(t_m).m_max_z-dbg_object(t_m).m_min_z);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1715>";
		dbg_object(m_collision).m_box_x=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1716>";
		dbg_object(m_collision).m_box_y=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1717>";
		dbg_object(m_collision).m_box_z=t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1718>";
		dbg_object(m_collision).m_box_w=t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1719>";
		dbg_object(m_collision).m_box_h=t_h;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1720>";
		dbg_object(m_collision).m_box_d=t_d;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1724>";
		if(dbg_object(m_collision).m_radius_x==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1725>";
			var t_c:Number=.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1726>";
			t_c=bb_math_Max2(bb_math_Max2(bb_math_Abs2(t_x),bb_math_Abs2(t_y)),bb_math_Abs2(t_z));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1727>";
			t_c=bb_math_Max2(bb_math_Max2(bb_math_Max2(t_c,bb_math_Abs2(t_x+t_w)),bb_math_Abs2(t_y+t_h)),bb_math_Abs2(t_z+t_d));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1730>";
			var t_xx:Number=t_c*1.4142135623;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1731>";
			dbg_object(m_collision).m_radius_x=Math.sqrt(t_xx*t_xx+t_c*t_c);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1734>";
		dbg_object(m_collision).m_updated_shape=false;
		popErr();
		return 0;
	}
	internal var m_anim_update:int=0;
	internal var m_anim_seqs_first:Array=new_number_array(1);
	internal var m_anim_seq:int=0;
	internal var m_anim_seqs_last:Array=new_number_array(1);
	internal var m_anim_trans:int=0;
	internal var m_anim_time:Number=.0;
	internal var m_anim_render:int=0;
	internal var m_anim_mode:int=0;
	internal var m_anim_speed:Number=.0;
	internal var m_anim_dir:int=1;
	internal var m_use_cam_layer:Boolean=false;
	internal var m_cam_layer:c_TCamera=null;
	internal var m_auto_fade:int=0;
	public function p_EntityDistanceSquared(t_ent2:c_TEntity):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1469>";
		var t_xd:Number=dbg_array(dbg_array(dbg_object(dbg_object(t_ent2).m_mat).m_grid,3)[dbg_index],0)[dbg_index]-dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1470>";
		var t_yd:Number=dbg_array(dbg_array(dbg_object(dbg_object(t_ent2).m_mat).m_grid,3)[dbg_index],1)[dbg_index]-dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1471>";
		var t_zd:Number=-dbg_array(dbg_array(dbg_object(dbg_object(t_ent2).m_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1473>";
		var t_:Number=t_xd*t_xd+t_yd*t_yd+t_zd*t_zd;
		popErr();
		return t_;
	}
	public function p_EntityDistance(t_ent2:c_TEntity):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1463>";
		var t_:Number=Math.sqrt(this.p_EntityDistanceSquared(t_ent2));
		popErr();
		return t_;
	}
	internal var m_fade_near:Number=.0;
	internal var m_fade_far:Number=.0;
	internal var m_fade_alpha:Number=.0;
	internal var m_using_alpha:Boolean=false;
	internal var m_alpha_order:Number=.0;
	public function p_EntityName():String{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<1340>";
		popErr();
		return m_name;
	}
	internal static var m_global_mat:c_Matrix;
	public function p_EntityBlend(t_blend_no:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<973>";
		dbg_object(m_brush).m_blend=t_blend_no;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<975>";
		if(((this) as c_TMesh)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<978>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<978>";
			var t_:c_Enumerator6=dbg_object((this) as c_TMesh).m_surf_list.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<978>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<978>";
				var t_surf:c_TSurface=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<979>";
				if(dbg_object(t_surf).m_brush!=null){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<980>";
					dbg_object(dbg_object(t_surf).m_brush).m_blend=dbg_object(m_brush).m_blend;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<985>";
		popErr();
		return this;
	}
	public function p_EntityColorFloat(t_r:Number,t_g:Number,t_b:Number,t_a:Number):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<891>";
		dbg_object(m_brush).m_red=t_r;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<892>";
		dbg_object(m_brush).m_green=t_g;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<893>";
		dbg_object(m_brush).m_blue=t_b;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<895>";
		if(t_a>=0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<895>";
			dbg_object(m_brush).m_alpha=t_a;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<896>";
		popErr();
		return this;
	}
}
class c_TMesh extends c_TEntity{
	public function m_TMesh_new():c_TMesh{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<50>";
		super.m_TEntity_new();
		popErr();
		return this;
	}
	public static function m_CreateMesh(t_parent_ent:c_TEntity):c_TMesh{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<203>";
		var t_mesh:c_TMesh=(new c_TMesh).m_TMesh_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<205>";
		dbg_object(t_mesh).m_classname="Mesh";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<207>";
		if((t_parent_ent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<207>";
			t_mesh.p_AddParent(t_parent_ent);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<208>";
		dbg_object(t_mesh).m_entity_link=c_TEntity.m_entity_list.p_EntityListAdd(t_mesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<211>";
		if(dbg_object(t_mesh).m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<212>";
			dbg_object(t_mesh).m_mat.p_Overwrite(dbg_object(dbg_object(t_mesh).m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<213>";
			t_mesh.p_UpdateMat(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<215>";
			t_mesh.p_UpdateMat(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<218>";
		popErr();
		return t_mesh;
	}
	internal var m_surf_list:c_List2=(new c_List2).m_List_new();
	internal var m_no_surfs:int=0;
	public function p_CreateSurfaceID():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<271>";
		m_no_surfs=m_no_surfs+1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<272>";
		var t_:int=m_no_surfs-1;
		popErr();
		return t_;
	}
	internal var m_anim_surf:Array=[];
	internal var m_anim_surf_frame:Array=[];
	internal var m_reset_bounds:int=1;
	internal var m_col_tree:c_TColTree=(new c_TColTree).m_TColTree_new();
	public function p_CreateSurface(t_bru:c_TBrush):c_TSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<278>";
		var t_surf:c_TSurface=(new c_TSurface).m_TSurface_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<279>";
		m_surf_list.p_AddLast2(t_surf);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<282>";
		if(t_bru!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<283>";
			dbg_object(t_surf).m_brush=t_bru.p_Copy();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<287>";
		dbg_object(t_surf).m_surf_id=this.p_CreateSurfaceID();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<288>";
		m_anim_surf=resize_object_array(m_anim_surf,m_no_surfs);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<289>";
		m_anim_surf_frame=resize_number_array(m_anim_surf_frame,m_no_surfs);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<292>";
		m_reset_bounds=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<293>";
		dbg_object(m_col_tree).m_reset_col_tree=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<295>";
		popErr();
		return t_surf;
	}
	public function p_AddSurface(t_surf:c_TSurface):c_TSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<303>";
		m_surf_list.p_AddLast2(t_surf);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<306>";
		dbg_object(t_surf).m_surf_id=this.p_CreateSurfaceID();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<307>";
		m_anim_surf=resize_object_array(m_anim_surf,m_no_surfs);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<308>";
		m_anim_surf_frame=resize_number_array(m_anim_surf_frame,m_no_surfs);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<311>";
		m_reset_bounds=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<312>";
		dbg_object(m_col_tree).m_reset_col_tree=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<314>";
		popErr();
		return t_surf;
	}
	internal var m_is_sprite:Boolean=false;
	public function p_Draw(t_x:Number,t_y:Number,t_no_scaling:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2067>";
		c_TRender.m_draw_list.p_AddLast3(this);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2069>";
		var t_w:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2070>";
		var t_h:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2071>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2071>";
			this.p_EntityParent(null,true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2073>";
		this.p_PositionEntity(t_x,t_y,1.99999,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2076>";
		var t_spr:c_TSprite=((this) as c_TSprite);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2077>";
		if(!t_no_scaling && t_spr!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2078>";
			dbg_array(dbg_object(t_spr).m_pixel_scale,0)[dbg_index]=1.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2079>";
			dbg_array(dbg_object(t_spr).m_pixel_scale,1)[dbg_index]=1.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2081>";
			if(((this) as c_TText)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2083>";
				var t_scx:Number=((dbg_object((this) as c_TText).m_char_pixels*dbg_object((this) as c_TText).m_pixel_ratio+1.5)|0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2084>";
				dbg_array(dbg_object(t_spr).m_pixel_scale,0)[dbg_index]=t_scx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2085>";
				dbg_array(dbg_object(t_spr).m_pixel_scale,1)[dbg_index]=t_scx;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2088>";
				var t_scx2:Number=(dbg_object(dbg_object(this).m_brush.p_GetTexture(0)).m_width)*0.5;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2089>";
				var t_scy:Number=(dbg_object(dbg_object(this).m_brush.p_GetTexture(0)).m_height)*0.5;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2091>";
				dbg_array(dbg_object(t_spr).m_pixel_scale,0)[dbg_index]=t_scx2;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2092>";
				dbg_array(dbg_object(t_spr).m_pixel_scale,1)[dbg_index]=t_scy;
			}
		}
		popErr();
		return 0;
	}
	public function p_GetTotalTris():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1816>";
		var t_t:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1817>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1817>";
		var t_:c_Enumerator6=m_surf_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1817>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1817>";
			var t_s:c_TSurface=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1818>";
			t_t=t_t+dbg_object(t_s).m_no_tris;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1820>";
		popErr();
		return t_t;
	}
	internal var m_total_tris:int=0;
	internal var m_min_x:Number=.0;
	internal var m_max_x:Number=.0;
	internal var m_min_y:Number=.0;
	internal var m_max_y:Number=.0;
	internal var m_min_z:Number=.0;
	internal var m_max_z:Number=.0;
	internal var m_vec_temp:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_vecbounds:Array=new_object_array(6);
	internal var m_center_x:Number=.0;
	internal var m_center_y:Number=.0;
	internal var m_center_z:Number=.0;
	public function p_GetBounds(t_reset:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1716>";
		if(m_reset_bounds==1 || t_reset==true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1719>";
			m_total_tris=this.p_GetTotalTris();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1721>";
			m_reset_bounds=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1723>";
			m_min_x=999999999.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1724>";
			m_max_x=-999999999.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1725>";
			m_min_y=999999999.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1726>";
			m_max_y=-999999999.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1727>";
			m_min_z=999999999.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1728>";
			m_max_z=-999999999.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1729>";
			var t_cc:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1731>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1731>";
			var t_:c_Enumerator6=m_surf_list.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1731>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1731>";
				var t_surf:c_TSurface=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1733>";
				t_cc+=1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1735>";
				for(var t_v:int=0;t_v<dbg_object(t_surf).m_no_verts;t_v=t_v+1){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1737>";
					dbg_object(t_surf).m_vert_data.p_GetVertCoords(m_vec_temp,t_v);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1739>";
					if(dbg_object(m_vec_temp).m_x<m_min_x){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1739>";
						m_min_x=dbg_object(m_vec_temp).m_x;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1739>";
						dbg_array(m_vecbounds,0)[dbg_index]=m_vec_temp.p_Copy();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1740>";
					if(dbg_object(m_vec_temp).m_x>m_max_x){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1740>";
						m_max_x=dbg_object(m_vec_temp).m_x;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1740>";
						dbg_array(m_vecbounds,1)[dbg_index]=m_vec_temp.p_Copy();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1742>";
					if(dbg_object(m_vec_temp).m_y<m_min_y){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1742>";
						m_min_y=dbg_object(m_vec_temp).m_y;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1742>";
						dbg_array(m_vecbounds,2)[dbg_index]=m_vec_temp.p_Copy();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1743>";
					if(dbg_object(m_vec_temp).m_y>m_max_y){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1743>";
						m_max_y=dbg_object(m_vec_temp).m_y;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1743>";
						dbg_array(m_vecbounds,3)[dbg_index]=m_vec_temp.p_Copy();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1745>";
					if(dbg_object(m_vec_temp).m_z<m_min_z){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1745>";
						m_min_z=dbg_object(m_vec_temp).m_z;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1745>";
						dbg_array(m_vecbounds,4)[dbg_index]=m_vec_temp.p_Copy();
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1746>";
					if(dbg_object(m_vec_temp).m_z>m_max_z){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1746>";
						m_max_z=dbg_object(m_vec_temp).m_z;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1746>";
						dbg_array(m_vecbounds,5)[dbg_index]=m_vec_temp.p_Copy();
					}
				}
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1754>";
			var t_width:Number=m_max_x-m_min_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1755>";
			var t_height:Number=m_max_y-m_min_y;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1756>";
			var t_depth:Number=m_max_z-m_min_z;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1757>";
			if(t_cc==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1757>";
				t_width=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1757>";
				t_height=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1757>";
				t_depth=0.0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1762>";
			if(m_cull_radius>=0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1764>";
				if(t_width>=t_height && t_width>=t_depth){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1765>";
					m_cull_radius=t_width;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1767>";
					if(t_height>=t_width && t_height>=t_depth){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1768>";
						m_cull_radius=t_height;
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1770>";
						m_cull_radius=t_depth;
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1774>";
				m_cull_radius=m_cull_radius*0.5;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1775>";
				var t_crs:Number=m_cull_radius*m_cull_radius;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1776>";
				m_cull_radius=Math.sqrt(t_crs+t_crs+t_crs);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1782>";
			m_center_x=m_min_x+t_width*0.5;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1783>";
			m_center_y=m_min_y+t_height*0.5;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1784>";
			m_center_z=m_min_z+t_depth*0.5;
		}
		popErr();
		return 0;
	}
	public function p_GetSphereBounds():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1793>";
		if(m_cull_radius==0.0 || m_reset_bounds==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1794>";
			this.p_GetBounds(false);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1797>";
		var t_center:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1798>";
		var t_ss:Number=dbg_array(m_vecbounds,0)[dbg_index].p_Distance(t_center);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1800>";
		for(var t_i:int=1;t_i<=5;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1801>";
			var t_j:Number=dbg_array(m_vecbounds,t_i)[dbg_index].p_Distance(t_center);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1802>";
			if(t_j>t_ss){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1804>";
				t_ss=t_j;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1811>";
		popErr();
		return t_ss;
	}
	internal var m_culled:Boolean=false;
	public function p_GetCulled():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2148>";
		popErr();
		return m_culled;
	}
	internal var m_bones:Array=[];
	public function p_GetAnimSurface(t_surf:c_TSurface):c_TSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1959>";
		popErr();
		return dbg_array(m_anim_surf,dbg_object(t_surf).m_surf_id)[dbg_index];
	}
	public function p_GetAnimSurface2(t_s:int):c_TSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1965>";
		if(t_s<0 || t_s>m_anim_surf.length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1965>";
			popErr();
			return null;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1966>";
		var t_:c_TSurface=dbg_array(m_anim_surf,t_s-1)[dbg_index];
		popErr();
		return t_;
	}
	internal var m_distance_nearplane:Number=.0;
	internal var m_wireframe:Boolean=false;
	public function p_AutoFade(t_cam:c_TCamera):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1690>";
		var t_dist:Number=t_cam.p_EntityDistance(this);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1692>";
		if(t_dist>m_fade_near && t_dist<m_fade_far){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1695>";
			m_fade_alpha=(t_dist-m_fade_near)/(m_fade_far-m_fade_near);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1700>";
			if(t_dist<m_fade_near){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1700>";
				m_fade_alpha=0.0;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1700>";
				m_fade_alpha=1.0;
			}
		}
		popErr();
		return 0;
	}
	public function p_Alpha():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1835>";
		var t_alpha:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1838>";
		if(dbg_object(m_brush).m_alpha<1.0 || dbg_object(m_brush).m_blend==2 || dbg_object(m_brush).m_blend==3 || ((dbg_object(m_brush).m_fx&32)!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1840>";
			t_alpha=true;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1847>";
			if(dbg_array(dbg_object(m_brush).m_tex,0)[dbg_index]!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1848>";
				if((dbg_object(dbg_array(dbg_object(m_brush).m_tex,0)[dbg_index]).m_flags&2)!=0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1849>";
					t_alpha=true;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1856>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1856>";
		var t_:c_Enumerator6=m_surf_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1856>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1856>";
			var t_surf:c_TSurface=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1858>";
			dbg_object(t_surf).m_alpha_enable=false;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1860>";
			if(dbg_object(t_surf).m_brush!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1862>";
				if(dbg_object(dbg_object(t_surf).m_brush).m_alpha<1.0 || dbg_object(dbg_object(t_surf).m_brush).m_blend==2 || dbg_object(dbg_object(t_surf).m_brush).m_blend==3 || ((dbg_object(dbg_object(t_surf).m_brush).m_fx&32)!=0)){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1864>";
					t_alpha=true;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1868>";
					if(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,0)[dbg_index]!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1869>";
						if((dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,0)[dbg_index]).m_flags&2)!=0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1870>";
							t_alpha=true;
						}
					}
				}
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1879>";
			if(m_fade_alpha!=0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1880>";
				t_alpha=true;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1884>";
			if(t_alpha==true){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1885>";
				dbg_object(t_surf).m_alpha_enable=true;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1890>";
		m_using_alpha=t_alpha;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1891>";
		popErr();
		return t_alpha;
	}
	public function p_UpdateVertexAnimFrame(t_surf:c_TSurface,t_orig_surf:c_TSurface):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2159>";
		if(!((t_surf)!=null)){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2161>";
		dbg_object(t_surf).m_anim_frame=dbg_array(dbg_object(this).m_anim_surf_frame,dbg_object(t_orig_surf).m_surf_id)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<2164>";
		dbg_object(t_surf).m_reset_vbo=dbg_object(t_surf).m_reset_vbo|1;
		popErr();
	}
	public function p_GetSurface(t_surf_no_get:int):c_TSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1524>";
		var t_surf_no:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1526>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1526>";
		var t_:c_Enumerator6=m_surf_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1526>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1526>";
			var t_surf:c_TSurface=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1528>";
			t_surf_no=t_surf_no+1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1530>";
			if(t_surf_no_get==t_surf_no){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1530>";
				popErr();
				return t_surf;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<1534>";
		popErr();
		return null;
	}
	public function p_RemoveFromRenderList():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<320>";
		m_entity_link.p_Remove();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tmesh.monkey<321>";
		m_entity_link=null;
		popErr();
	}
}
class c_Matrix extends Object{
	internal var m_grid:Array=new_array_array(4);
	public function m_Matrix_new():c_Matrix{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<29>";
		m_grid=[[0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0]];
		popErr();
		return this;
	}
	public function m_Matrix_new2(t_a:c_Vector,t_b:c_Vector,t_c:c_Vector):c_Matrix{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<36>";
		dbg_array(m_grid,0)[dbg_index]=[dbg_object(t_a).m_x,dbg_object(t_a).m_y,dbg_object(t_a).m_z,0.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<37>";
		dbg_array(m_grid,1)[dbg_index]=[dbg_object(t_b).m_x,dbg_object(t_b).m_y,dbg_object(t_b).m_z,0.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<38>";
		dbg_array(m_grid,2)[dbg_index]=[dbg_object(t_c).m_x,dbg_object(t_c).m_y,dbg_object(t_c).m_z,0.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<39>";
		dbg_array(m_grid,3)[dbg_index]=[0.0,0.0,0.0,1.0];
		popErr();
		return this;
	}
	public function p_LoadIdentity():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<46>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<46>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<46>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<46>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<47>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<47>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<47>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<47>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<48>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<48>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<48>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<48>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<49>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<49>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<49>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<49>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]=1.0;
		popErr();
	}
	public function p_Overwrite(t_mat:c_Matrix):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<87>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<88>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<89>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<90>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<91>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<92>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<93>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<94>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<95>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<96>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<97>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<98>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<100>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<101>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<102>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<103>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		popErr();
	}
	public function p_Translate(t_x:Number,t_y:Number,t_z:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<314>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*t_y+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*t_z+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<315>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*t_x+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*t_z+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<316>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*t_x+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*t_y+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index];
		popErr();
	}
	public function p_Rotate(t_rx:Number,t_ry:Number,t_rz:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_cos_ang:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_sin_ang:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_m20:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_m21:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_m22:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_m00:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_m01:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_m02:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_r1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_r2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<454>";
		var t_r3:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<458>";
		t_cos_ang=Math.cos((t_ry)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<459>";
		t_sin_ang=Math.sin((t_ry)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<461>";
		t_m00=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*t_cos_ang+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*-t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<462>";
		t_m01=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*t_cos_ang+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*-t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<463>";
		t_m02=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*t_cos_ang+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*-t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<465>";
		t_m20=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*t_sin_ang+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<466>";
		t_m21=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*t_sin_ang+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<467>";
		t_m22=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*t_sin_ang+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<471>";
		t_cos_ang=Math.cos((t_rx)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<472>";
		t_sin_ang=Math.sin((t_rx)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<474>";
		var t_m10:Number=dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*t_cos_ang+t_m20*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<475>";
		var t_m11:Number=dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*t_cos_ang+t_m21*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<476>";
		var t_m12:Number=dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*t_cos_ang+t_m22*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<478>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*-t_sin_ang+t_m20*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<479>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*-t_sin_ang+t_m21*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<480>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*-t_sin_ang+t_m22*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<484>";
		t_cos_ang=Math.cos((t_rz)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<485>";
		t_sin_ang=Math.sin((t_rz)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<487>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=t_m00*t_cos_ang+t_m10*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<488>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=t_m01*t_cos_ang+t_m11*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<489>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=t_m02*t_cos_ang+t_m12*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<491>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=t_m00*-t_sin_ang+t_m10*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<492>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=t_m01*-t_sin_ang+t_m11*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<493>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=t_m02*-t_sin_ang+t_m12*t_cos_ang;
		popErr();
	}
	public function p_Scale(t_sx:Number,t_sy:Number,t_sz:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<359>";
		if(t_sx==1.0 && t_sy==1.0 && t_sz==1.0){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<361>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*t_sx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<362>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*t_sx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<363>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*t_sx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<365>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*t_sy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<366>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*t_sy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<367>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*t_sy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<369>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*t_sz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<370>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*t_sz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<371>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*t_sz;
		popErr();
	}
	public function p_Copy():c_Matrix{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<57>";
		var t_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<59>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<60>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<61>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<62>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<64>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<65>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<66>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<67>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<69>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<70>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<71>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<72>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<74>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<75>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<76>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<77>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<79>";
		popErr();
		return t_mat;
	}
	public function p_Inverse():c_Matrix{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<112>";
		var t_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<114>";
		var t_tx:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<115>";
		var t_ty:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<116>";
		var t_tz:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<120>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<121>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<122>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<124>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<125>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<126>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<128>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<129>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<130>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<136>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<137>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<138>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<139>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index]=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<142>";
		t_tx=dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<143>";
		t_ty=dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<144>";
		t_tz=dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<147>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]=-(dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*t_tx+dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*t_ty+dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*t_tz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<148>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]=-(dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*t_tx+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*t_ty+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*t_tz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<149>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]=-(dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*t_tx+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*t_ty+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*t_tz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<151>";
		popErr();
		return t_mat;
	}
	public function p_TransformPoint(t_x:Number,t_y:Number,t_z:Number,t_w:Number):Array{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<596>";
		var t_p0:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<596>";
		var t_p1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<596>";
		var t_p2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<596>";
		var t_p3:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<600>";
		t_p0=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*t_y+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*t_z+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<601>";
		t_p1=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*t_x+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*t_z+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<602>";
		t_p2=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*t_x+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*t_y+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<605>";
		var t_:Array=[t_p0,t_p1,t_p2];
		popErr();
		return t_;
	}
	public function p_Multiply(t_mat:c_Matrix):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<215>";
		var t_m00:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<216>";
		var t_m01:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<217>";
		var t_m02:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<219>";
		var t_m10:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<220>";
		var t_m11:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<221>";
		var t_m12:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<223>";
		var t_m20:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<224>";
		var t_m21:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<225>";
		var t_m22:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<227>";
		var t_m30:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<228>";
		var t_m31:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<229>";
		var t_m32:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<232>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=t_m00;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<233>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=t_m01;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<234>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=t_m02;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<236>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=t_m10;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<237>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=t_m11;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<238>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=t_m12;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<240>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=t_m20;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<241>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=t_m21;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<242>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=t_m22;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<244>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]=t_m30;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<245>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]=t_m31;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<246>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]=t_m32;
		popErr();
	}
	public function p_Multiply2(t_v1:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<292>";
		var t_v2:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<294>";
		dbg_object(t_v2).m_x=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_object(t_v1).m_x+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_object(t_v1).m_y+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_object(t_v1).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<295>";
		dbg_object(t_v2).m_y=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_object(t_v1).m_x+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_object(t_v1).m_y+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_object(t_v1).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<296>";
		dbg_object(t_v2).m_z=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_object(t_v1).m_x+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_object(t_v1).m_y+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_object(t_v1).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<298>";
		popErr();
		return t_v2;
	}
	public function p_Multiply3(t_q:c_Line):c_Line{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<610>";
		var t_t:c_Vector=this.p_Multiply2(dbg_object(t_q).m_o);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<611>";
		var t_:c_Line=(new c_Line).m_Line_new2(t_t,this.p_Multiply2(dbg_object(t_q).m_o.p_Add(dbg_object(t_q).m_d)).p_Subtract(t_t));
		popErr();
		return t_;
	}
	public function p_CreateMatrix(t_rx:Number,t_ry:Number,t_rz:Number,t_scx:Number,t_scy:Number,t_scz:Number,t_px:Number,t_py:Number,t_pz:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<407>";
		var t_sx:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<407>";
		var t_sy:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<407>";
		var t_sz:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<407>";
		var t_cx:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<407>";
		var t_cy:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<407>";
		var t_cz:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<407>";
		var t_theta:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<410>";
		t_sx=Math.sin((t_rx)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<411>";
		t_cx=Math.cos((t_rx)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<414>";
		t_sy=Math.sin((t_ry)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<415>";
		t_cy=Math.cos((t_ry)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<418>";
		t_sz=Math.sin((t_rz)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<419>";
		t_cz=Math.cos((t_rz)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<421>";
		var t_sycz:Number=t_sy*t_cz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<422>";
		var t_cysz:Number=t_cy*t_sz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<423>";
		var t_sysz:Number=t_sy*t_sz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<424>";
		var t_cycz:Number=t_cy*t_cz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<427>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=(t_cycz+t_sysz*t_sx)*t_scx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<428>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=t_cx*t_sz*t_scx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<429>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=(-t_sycz+t_cysz*t_sx)*t_scx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<430>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<433>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=(-t_cysz+t_sycz*t_sx)*t_scy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<434>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=t_cx*t_cz*t_scy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<435>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=(t_sysz+t_cycz*t_sx)*t_scy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<436>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<439>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=t_sy*t_cx*t_scz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<440>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=-t_sx*t_scz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<441>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=t_cx*t_cy*t_scz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<442>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<444>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]=t_px;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<445>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]=t_py;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<446>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]=t_pz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<447>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]=1.0;
		popErr();
	}
	public function p_FastRotateScale(t_rx:Number,t_ry:Number,t_rz:Number,t_scx:Number,t_scy:Number,t_scz:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<401>";
		this.p_CreateMatrix(t_rx,t_ry,t_rz,t_scx,t_scy,t_scz,dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index],dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index],dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]);
		popErr();
	}
	public function p_Multiply4(t_mat:c_Matrix):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<254>";
		var t_m00:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<255>";
		var t_m01:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<256>";
		var t_m02:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<257>";
		var t_m03:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<258>";
		var t_m10:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<259>";
		var t_m11:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<260>";
		var t_m12:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<261>";
		var t_m13:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<262>";
		var t_m20:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<263>";
		var t_m21:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<264>";
		var t_m22:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<265>";
		var t_m23:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<266>";
		var t_m30:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<267>";
		var t_m31:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<268>";
		var t_m32:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<269>";
		var t_m33:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]+dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]*dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<271>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=t_m00;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<272>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=t_m01;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<273>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=t_m02;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<274>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]=t_m03;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<275>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=t_m10;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<276>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=t_m11;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<277>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=t_m12;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<278>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]=t_m13;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<279>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=t_m20;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<280>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=t_m21;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<281>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=t_m22;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<282>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]=t_m23;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<283>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]=t_m30;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<284>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]=t_m31;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<285>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]=t_m32;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<286>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]=t_m33;
		popErr();
	}
	public function p_Multiply42(t_v1:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<303>";
		var t_v2:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<305>";
		dbg_object(t_v2).m_x=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*dbg_object(t_v1).m_x+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*dbg_object(t_v1).m_y+dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]*dbg_object(t_v1).m_z+dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<306>";
		dbg_object(t_v2).m_y=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*dbg_object(t_v1).m_x+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*dbg_object(t_v1).m_y+dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]*dbg_object(t_v1).m_z+dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<307>";
		dbg_object(t_v2).m_z=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*dbg_object(t_v1).m_x+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*dbg_object(t_v1).m_y+dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]*dbg_object(t_v1).m_z+dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<309>";
		popErr();
		return t_v2;
	}
	public function p_ToArray():Array{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<633>";
		var t_arr:Array=new_number_array(16);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<635>";
		dbg_array(t_arr,0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<635>";
		dbg_array(t_arr,1)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<635>";
		dbg_array(t_arr,2)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<635>";
		dbg_array(t_arr,3)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<636>";
		dbg_array(t_arr,4)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<636>";
		dbg_array(t_arr,5)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<636>";
		dbg_array(t_arr,6)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<636>";
		dbg_array(t_arr,7)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<637>";
		dbg_array(t_arr,8)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<637>";
		dbg_array(t_arr,9)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<637>";
		dbg_array(t_arr,10)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<637>";
		dbg_array(t_arr,11)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<638>";
		dbg_array(t_arr,12)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<638>";
		dbg_array(t_arr,13)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<638>";
		dbg_array(t_arr,14)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<638>";
		dbg_array(t_arr,15)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<640>";
		popErr();
		return t_arr;
	}
	public function p_ToArray2(t_arr:Array):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<646>";
		dbg_array(t_arr,0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<646>";
		dbg_array(t_arr,1)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<646>";
		dbg_array(t_arr,2)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<646>";
		dbg_array(t_arr,3)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<647>";
		dbg_array(t_arr,4)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<647>";
		dbg_array(t_arr,5)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<647>";
		dbg_array(t_arr,6)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<647>";
		dbg_array(t_arr,7)[dbg_index]=dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<648>";
		dbg_array(t_arr,8)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<648>";
		dbg_array(t_arr,9)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<648>";
		dbg_array(t_arr,10)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<648>";
		dbg_array(t_arr,11)[dbg_index]=dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<649>";
		dbg_array(t_arr,12)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<649>";
		dbg_array(t_arr,13)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<649>";
		dbg_array(t_arr,14)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<649>";
		dbg_array(t_arr,15)[dbg_index]=dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index];
		popErr();
	}
	internal static var m_temp:c_Matrix;
	public function p_Transpose():c_Matrix{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<332>";
		m_temp.p_Overwrite(this);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<334>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,0)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<335>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,0)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<336>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,0)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<337>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<339>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,1)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<340>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,1)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<341>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,1)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<342>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<344>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,2)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<345>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,2)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<346>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,2)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<347>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<349>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<350>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<351>";
		dbg_array(dbg_array(m_grid,2)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<352>";
		dbg_array(dbg_array(m_grid,3)[dbg_index],3)[dbg_index]=dbg_array(dbg_array(dbg_object(m_temp).m_grid,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<354>";
		popErr();
		return this;
	}
	public function p_RotateRoll(t_ang:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<539>";
		var t_cos_ang:Number=Math.cos((t_ang)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<540>";
		var t_sin_ang:Number=Math.sin((t_ang)*D2R);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<542>";
		var t_m00:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*t_cos_ang+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<543>";
		var t_m01:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*t_cos_ang+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<544>";
		var t_m02:Number=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*t_cos_ang+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*t_sin_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<546>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]*-t_sin_ang+dbg_array(dbg_array(m_grid,1)[dbg_index],0)[dbg_index]*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<547>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]*-t_sin_ang+dbg_array(dbg_array(m_grid,1)[dbg_index],1)[dbg_index]*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<548>";
		dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]=dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]*-t_sin_ang+dbg_array(dbg_array(m_grid,1)[dbg_index],2)[dbg_index]*t_cos_ang;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<550>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],0)[dbg_index]=t_m00;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<551>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],1)[dbg_index]=t_m01;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/matrix.monkey<552>";
		dbg_array(dbg_array(m_grid,0)[dbg_index],2)[dbg_index]=t_m02;
		popErr();
	}
}
class c_Vector extends Object{
	internal var m_x:Number=.0;
	internal var m_y:Number=.0;
	internal var m_z:Number=.0;
	public function m_Vector_new(t_xx:Number,t_yy:Number,t_zz:Number):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<11>";
		m_x=t_xx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<12>";
		m_y=t_yy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<13>";
		m_z=t_zz;
		popErr();
		return this;
	}
	public function p_Add(t_vec:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<31>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x+dbg_object(t_vec).m_x,m_y+dbg_object(t_vec).m_y,m_z+dbg_object(t_vec).m_z);
		popErr();
		return t_;
	}
	public function p_Add2(t_vx:Number,t_vy:Number,t_vz:Number):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<37>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x+t_vx,m_y+t_vy,m_z+t_vz);
		popErr();
		return t_;
	}
	public function p_Subtract(t_vec:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<43>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x-dbg_object(t_vec).m_x,m_y-dbg_object(t_vec).m_y,m_z-dbg_object(t_vec).m_z);
		popErr();
		return t_;
	}
	public function p_Subtract2(t_vx:Number,t_vy:Number,t_vz:Number):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<49>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x-t_vx,m_y-t_vy,m_z-t_vz);
		popErr();
		return t_;
	}
	public function p_Copy():c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<25>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x,m_y,m_z);
		popErr();
		return t_;
	}
	public function p_Normalize():c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<98>";
		if(m_x==0.0 && m_y==0.0 && m_z==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<98>";
			var t_:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
			popErr();
			return t_;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<100>";
		var t_d:Number=1.0/Math.sqrt(m_x*m_x+m_y*m_y+m_z*m_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<101>";
		var t_2:c_Vector=(new c_Vector).m_Vector_new(m_x*t_d,m_y*t_d,m_z*t_d);
		popErr();
		return t_2;
	}
	public function p_Dot(t_vec:c_Vector):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<86>";
		var t_:Number=m_x*dbg_object(t_vec).m_x+m_y*dbg_object(t_vec).m_y+m_z*dbg_object(t_vec).m_z;
		popErr();
		return t_;
	}
	public function p_Cross(t_vec:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<92>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_y*dbg_object(t_vec).m_z-m_z*dbg_object(t_vec).m_y,m_z*dbg_object(t_vec).m_x-m_x*dbg_object(t_vec).m_z,m_x*dbg_object(t_vec).m_y-m_y*dbg_object(t_vec).m_x);
		popErr();
		return t_;
	}
	public function p_Update(t_xx:Number,t_yy:Number,t_zz:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<201>";
		m_x=t_xx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<201>";
		m_y=t_yy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<201>";
		m_z=t_zz;
		popErr();
		return 0;
	}
	public function p_Overwrite2(t_xx:Number,t_yy:Number,t_zz:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<205>";
		m_x=t_xx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<205>";
		m_y=t_yy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<205>";
		m_z=t_zz;
		popErr();
		return 0;
	}
	public function p_Overwrite3(t_v:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<209>";
		m_x=dbg_object(t_v).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<209>";
		m_y=dbg_object(t_v).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<209>";
		m_z=dbg_object(t_v).m_z;
		popErr();
		return 0;
	}
	public function p_Distance(t_q:c_Vector):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<138>";
		var t_xx:Number=m_x-dbg_object(t_q).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<139>";
		var t_yy:Number=m_y-dbg_object(t_q).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<140>";
		var t_zz:Number=m_z-dbg_object(t_q).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<141>";
		var t_:Number=Math.sqrt(t_xx*t_xx+t_yy*t_yy+t_zz*t_zz);
		popErr();
		return t_;
	}
	public function p_Length():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<114>";
		var t_:Number=Math.sqrt(m_x*m_x+m_y*m_y+m_z*m_z);
		popErr();
		return t_;
	}
	public function p_DistanceSquared():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<126>";
		var t_:Number=m_x*m_x+m_y*m_y+m_z*m_z;
		popErr();
		return t_;
	}
	public function p_DistanceSquared2(t_q:c_Vector):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<131>";
		var t_xx:Number=m_x-dbg_object(t_q).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<132>";
		var t_yy:Number=m_y-dbg_object(t_q).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<133>";
		var t_zz:Number=m_z-dbg_object(t_q).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<134>";
		var t_:Number=t_xx*t_xx+t_yy*t_yy+t_zz*t_zz;
		popErr();
		return t_;
	}
	public function p_Multiply2(t_v:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<55>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x*dbg_object(t_v).m_x,m_y*dbg_object(t_v).m_y,m_z*dbg_object(t_v).m_z);
		popErr();
		return t_;
	}
	public function p_Multiply5(t_val:Number):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<61>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x*t_val,m_y*t_val,m_z*t_val);
		popErr();
		return t_;
	}
	public function p_Multiply6(t_a:Number,t_b:Number,t_c:Number):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<67>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_x*t_a,m_y*t_b,m_z*t_c);
		popErr();
		return t_;
	}
	public function p_PointOnSegment(t_o:c_Vector,t_d:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<183>";
		var t_d2:c_Vector=t_d.p_Subtract(t_o);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<185>";
		var t_dx:Number=m_x-dbg_object(t_o).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<186>";
		var t_dy:Number=m_y-dbg_object(t_o).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<187>";
		var t_dz:Number=m_z-dbg_object(t_o).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<188>";
		var t_v:Number=(dbg_object(t_d2).m_x*t_dx+dbg_object(t_d2).m_y*t_dy+dbg_object(t_d2).m_z*t_dz)/(dbg_object(t_d2).m_x*dbg_object(t_d2).m_x+dbg_object(t_d2).m_y*dbg_object(t_d2).m_y+dbg_object(t_d2).m_z*dbg_object(t_d2).m_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<189>";
		if(t_v>1.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<189>";
			popErr();
			return t_d;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<190>";
		if(t_v<0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<190>";
			popErr();
			return t_o;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vector.monkey<191>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(dbg_object(t_o).m_x+dbg_object(t_d2).m_x*t_v,dbg_object(t_o).m_y+dbg_object(t_d2).m_y*t_v,dbg_object(t_o).m_z+dbg_object(t_d2).m_z*t_v);
		popErr();
		return t_;
	}
}
class c_TCollision extends Object{
	public function m_TCollision_new():c_TCollision{
		pushErr();
		popErr();
		return this;
	}
	internal var m_updated_shape:Boolean=false;
	internal var m_no_collisions:int=0;
	internal var m_impact:Array=[];
	public function p_ClearImpact():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<142>";
		m_no_collisions=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<143>";
		m_impact=new_object_array(0);
		popErr();
	}
	internal var m_radius_x:Number=0.0;
	internal var m_radius_y:Number=0.0;
	internal var m_box_w:Number=0.0;
	internal var m_box_x:Number=0.0;
	internal var m_box_y:Number=0.0;
	internal var m_box_z:Number=0.0;
	internal var m_box_h:Number=0.0;
	internal var m_box_d:Number=0.0;
	internal var m_old_px:Number=.0;
	internal var m_old_py:Number=.0;
	internal var m_old_pz:Number=.0;
	public function p_MoveTest(t_ent:c_TEntity):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<78>";
		if(m_old_px==dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index] && m_old_py==dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index] && m_old_pz==-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index]){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<87>";
			popErr();
			return false;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<90>";
		popErr();
		return true;
	}
	internal var m_old_rz:Number=.0;
	internal var m_old_ry:Number=.0;
	internal var m_old_rx:Number=.0;
	public function p_SetOldPosition(t_ent:c_TEntity,t_x:Number,t_y:Number,t_z:Number):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<94>";
		m_old_px=dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<94>";
		m_old_py=dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<94>";
		m_old_pz=-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<95>";
		m_old_rz=dbg_object(t_ent).m_rz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<95>";
		m_old_ry=dbg_object(t_ent).m_ry;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<95>";
		m_old_rx=dbg_object(t_ent).m_rx;
		popErr();
	}
	internal var m_sa:Array=new_number_array(6);
	internal var m_old_dst_radius:Number=.0;
	internal var m_old_gsx:Number=.0;
	internal var m_old_gsy:Number=.0;
	internal var m_old_gsz:Number=.0;
	internal var m_old_igsx:Number=.0;
	internal var m_old_igsy:Number=.0;
	internal var m_old_igsz:Number=.0;
	public function p_CreateImpact(t_ent2_hit:c_TEntity,t_coll_obj:c_CollisionObject):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<150>";
		m_no_collisions=m_no_collisions+1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<152>";
		var t_i:int=m_no_collisions-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<153>";
		m_impact=resize_object_array(m_impact,t_i+1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<155>";
		dbg_array(m_impact,t_i)[dbg_index]=(new c_TCollisionImpact).m_TCollisionImpact_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<156>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_x=dbg_object(dbg_object(t_coll_obj).m_col_coords).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<157>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_y=dbg_object(dbg_object(t_coll_obj).m_col_coords).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<158>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_z=dbg_object(dbg_object(t_coll_obj).m_col_coords).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<159>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_nx=dbg_object(dbg_object(t_coll_obj).m_normal).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<160>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_ny=dbg_object(dbg_object(t_coll_obj).m_normal).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<161>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_nz=dbg_object(dbg_object(t_coll_obj).m_normal).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<162>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_ent=t_ent2_hit;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<164>";
		if(((t_ent2_hit) as c_TMesh)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<165>";
			dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_surf=dbg_object(t_coll_obj).m_surface;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<167>";
			dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_surf=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<171>";
		dbg_object(dbg_array(m_impact,t_i)[dbg_index]).m_tri=dbg_object(t_coll_obj).m_index;
		popErr();
	}
}
class c_List extends Object{
	public function m_List_new():c_List{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node2=((new c_HeadNode).m_HeadNode_new());
	public function p_AddLast(t_data:c_TEntity):c_Node2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node2=(new c_Node2).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TEntity=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast(t_t);
		}
		popErr();
		return this;
	}
	public function p_FirstNode():c_Node2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<62>";
		if(dbg_object(m__head).m__succ!=m__head){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<62>";
			popErr();
			return dbg_object(m__head).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<63>";
		popErr();
		return null;
	}
	public function p_AddFirst(t_data:c_TEntity):c_Node2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<104>";
		var t_:c_Node2=(new c_Node2).m_Node_new(dbg_object(m__head).m__succ,m__head,t_data);
		popErr();
		return t_;
	}
	public function p_IsEmpty():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<50>";
		var t_:Boolean=dbg_object(m__head).m__succ==m__head;
		popErr();
		return t_;
	}
	public function p_ObjectEnumerator():c_Enumerator2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator2=(new c_Enumerator2).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_EntityList extends c_List{
	public function m_EntityList_new():c_EntityList{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2343>";
		super.m_List_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2343>";
		popErr();
		return this;
	}
	public function p_EntityListAdd(t_obj:c_TEntity):c_Node2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2349>";
		var t_llink:c_Node2=this.p_FirstNode();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2351>";
		if(dbg_object(t_obj).m_order>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2355>";
			t_llink=this.p_AddFirst(t_obj);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2357>";
			popErr();
			return t_llink;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2364>";
			t_llink=this.p_AddLast(t_obj);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2366>";
			popErr();
			return t_llink;
		}
		return null;
	}
}
class c_Node2 extends Object{
	internal var m__succ:c_Node2=null;
	internal var m__pred:c_Node2=null;
	internal var m__data:c_TEntity=null;
	public function m_Node_new(t_succ:c_Node2,t_pred:c_Node2,t_data:c_TEntity):c_Node2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
	public function p_Remove():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<274>";
		if(dbg_object(m__succ).m__pred!=this){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<274>";
			error("Illegal operation on removed node");
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<276>";
		dbg_object(m__succ).m__pred=m__pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<277>";
		dbg_object(m__pred).m__succ=m__succ;
		popErr();
		return 0;
	}
}
class c_HeadNode extends c_Node2{
	public function m_HeadNode_new():c_HeadNode{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
internal function bb_functions_CreateMesh(t_parent:c_TEntity):c_TMesh{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<466>";
	var t_:c_TMesh=c_TMesh.m_CreateMesh(t_parent);
	popErr();
	return t_;
}
class c_TBrush extends Object{
	public function m_TBrush_new():c_TBrush{
		pushErr();
		popErr();
		return this;
	}
	internal var m_red:Number=1.0;
	internal var m_green:Number=1.0;
	internal var m_blue:Number=1.0;
	internal var m_tex:Array=new_object_array(8);
	public function m_TBrush_new2(t_hexcolor:int):c_TBrush{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<40>";
		m_red=((t_hexcolor&16711680)>>16)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<41>";
		m_green=((t_hexcolor&65280)>>8)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<42>";
		m_blue=(t_hexcolor&255)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<43>";
		dbg_array(m_tex,0)[dbg_index]=(new c_TTexture).m_TTexture_new();
		popErr();
		return this;
	}
	public function m_TBrush_new3(t_r:int,t_g:int,t_b:int):c_TBrush{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<49>";
		m_red=(t_r)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<50>";
		m_green=(t_g)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<51>";
		m_blue=(t_b)*0.0039215686274509803;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<52>";
		dbg_array(m_tex,0)[dbg_index]=(new c_TTexture).m_TTexture_new();
		popErr();
		return this;
	}
	internal var m_no_texs:int=0;
	public function p_BrushTexture(t_texture:c_TTexture,t_frame:int,t_index:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<204>";
		dbg_array(m_tex,t_index)[dbg_index]=t_texture;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<205>";
		if(t_index+1>m_no_texs){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<205>";
			m_no_texs=t_index+1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<207>";
		if(t_frame<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<207>";
			t_frame=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<208>";
		if(t_frame>dbg_object(t_texture).m_no_frames-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<208>";
			t_frame=dbg_object(t_texture).m_no_frames-1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<209>";
		dbg_object(t_texture).m_tex_frame=t_frame;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<211>";
		if(t_frame>0 && dbg_object(t_texture).m_no_frames>1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<213>";
			var t_x:int=t_frame % dbg_object(t_texture).m_frame_xstep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<214>";
			var t_y:int=((t_frame/dbg_object(t_texture).m_frame_ystep)|0) % dbg_object(t_texture).m_frame_ystep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<215>";
			dbg_object(t_texture).m_u_pos=(t_x)*dbg_object(t_texture).m_frame_ustep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<216>";
			dbg_object(t_texture).m_v_pos=(t_y)*dbg_object(t_texture).m_frame_vstep;
		}
		popErr();
	}
	public function m_TBrush_new4(t_texture:c_TTexture):c_TBrush{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<57>";
		this.p_BrushTexture(t_texture,0,0);
		popErr();
		return this;
	}
	internal var m_fx:int=0;
	internal var m_name:String="";
	internal var m_alpha:Number=1.0;
	internal var m_shine:Number=0.05;
	internal var m_shine_strength:Number=100.0;
	internal var m_blend:int=0;
	public function p_Copy():c_TBrush{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<62>";
		var t_brush:c_TBrush=(new c_TBrush).m_TBrush_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<64>";
		dbg_object(t_brush).m_no_texs=m_no_texs;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<65>";
		dbg_object(t_brush).m_name=m_name;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<66>";
		dbg_object(t_brush).m_red=m_red;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<67>";
		dbg_object(t_brush).m_green=m_green;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<68>";
		dbg_object(t_brush).m_blue=m_blue;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<69>";
		dbg_object(t_brush).m_alpha=m_alpha;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<70>";
		dbg_object(t_brush).m_shine=m_shine;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<71>";
		dbg_object(t_brush).m_shine_strength=m_shine_strength;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<72>";
		dbg_object(t_brush).m_blend=m_blend;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<73>";
		dbg_object(t_brush).m_fx=m_fx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<84>";
		if((dbg_array(m_tex,0)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<84>";
			dbg_array(dbg_object(t_brush).m_tex,0)[dbg_index]=dbg_array(m_tex,0)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<85>";
		if((dbg_array(m_tex,1)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<85>";
			dbg_array(dbg_object(t_brush).m_tex,1)[dbg_index]=dbg_array(m_tex,1)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<86>";
		if((dbg_array(m_tex,2)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<86>";
			dbg_array(dbg_object(t_brush).m_tex,2)[dbg_index]=dbg_array(m_tex,2)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<87>";
		if((dbg_array(m_tex,3)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<87>";
			dbg_array(dbg_object(t_brush).m_tex,3)[dbg_index]=dbg_array(m_tex,3)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<88>";
		if((dbg_array(m_tex,4)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<88>";
			dbg_array(dbg_object(t_brush).m_tex,4)[dbg_index]=dbg_array(m_tex,4)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<89>";
		if((dbg_array(m_tex,5)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<89>";
			dbg_array(dbg_object(t_brush).m_tex,5)[dbg_index]=dbg_array(m_tex,5)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<90>";
		if((dbg_array(m_tex,6)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<90>";
			dbg_array(dbg_object(t_brush).m_tex,6)[dbg_index]=dbg_array(m_tex,6)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<91>";
		if((dbg_array(m_tex,7)[dbg_index])!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<91>";
			dbg_array(dbg_object(t_brush).m_tex,7)[dbg_index]=dbg_array(m_tex,7)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<93>";
		popErr();
		return t_brush;
	}
	public function p_GetTexture(t_index:int):c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbrush.monkey<223>";
		popErr();
		return dbg_array(m_tex,t_index)[dbg_index];
	}
}
class c_TTexture extends Object{
	internal static var m_useGlobalResizeSmooth:Boolean;
	internal var m_resize_smooth:Boolean=false;
	public function m_TTexture_new():c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<87>";
		m_resize_smooth=m_useGlobalResizeSmooth;
		popErr();
		return this;
	}
	internal var m_no_frames:int=1;
	internal var m_tex_frame:int=0;
	internal var m_frame_xstep:int=0;
	internal var m_frame_ystep:int=0;
	internal var m_frame_ustep:Number=1.0;
	internal var m_u_pos:Number=.0;
	internal var m_frame_vstep:Number=1.0;
	internal var m_v_pos:Number=.0;
	internal var m_file:String="";
	internal var m_flags:int=0;
	public function p_FilterFlags():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<692>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<692>";
		var t_:c_Enumerator4=c_TTextureFilter.m_filter_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<692>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<692>";
			var t_filter:c_TTextureFilter=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<693>";
			var t_len1:int=dbg_object(t_filter).m_text.length;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<694>";
			var t_len2:int=m_file.length-t_len1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<695>";
			var t_file2:String=m_file.slice(t_len2);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<696>";
			if(t_file2==dbg_object(t_filter).m_text){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<696>";
				m_flags=m_flags|dbg_object(t_filter).m_flags;
			}
		}
		popErr();
		return 0;
	}
	internal static var m_tex_list:c_List9;
	public function p_TexInList():c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<677>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<677>";
		var t_:c_Enumerator5=m_tex_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<677>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<677>";
			var t_tex:c_TTexture=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<678>";
			if(m_file==dbg_object(t_tex).m_file && m_flags==dbg_object(t_tex).m_flags){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<680>";
				popErr();
				return t_tex;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<685>";
		popErr();
		return null;
	}
	internal var m_tex_link:c_Node11=null;
	internal var m_pixmap:c_TPixmap=null;
	internal var m_orig_width:int=0;
	internal var m_orig_height:int=0;
	public static function m_Pow2Size(t_n:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<726>";
		var t_t:int=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<727>";
		while(t_t<t_n){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<728>";
			t_t=t_t<<1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<730>";
		popErr();
		return t_t;
	}
	public static function m_AdjustPixmap(t_pixmap:c_TPixmap,t_resize_smooth:Boolean,t_tex:c_TTexture):c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<704>";
		var t_width:int=m_Pow2Size(dbg_object(t_pixmap).m_width);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<705>";
		var t_height:int=m_Pow2Size(dbg_object(t_pixmap).m_height);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<709>";
		if(t_width!=dbg_object(t_pixmap).m_width || t_height!=dbg_object(t_pixmap).m_height){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<717>";
			if(t_resize_smooth){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<717>";
				t_pixmap=t_pixmap.p_ResizePixmap(t_width,t_height);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<717>";
				t_pixmap=t_pixmap.p_ResizePixmapNoSmooth(t_width,t_height);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<721>";
		popErr();
		return t_pixmap;
	}
	internal var m_width:int=0;
	internal var m_height:int=0;
	internal var m_frame_startx:int=0;
	internal var m_frame_starty:int=0;
	internal var m_u_scale:Number=1.0;
	internal var m_v_scale:Number=1.0;
	public function p_SetAnimationFrames(t_first_frame:int,t_frame_count:int,t_frame_width:int,t_frame_height:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<329>";
		m_frame_xstep=((dbg_object(m_pixmap).m_width/t_frame_width)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<330>";
		m_frame_ystep=((dbg_object(m_pixmap).m_height/t_frame_height)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<332>";
		m_frame_startx=t_first_frame % m_frame_xstep;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<333>";
		m_frame_starty=((t_first_frame/m_frame_ystep)|0) % m_frame_ystep;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<335>";
		if(t_frame_count<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<336>";
			t_frame_count=m_frame_xstep*m_frame_ystep;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<339>";
		m_no_frames=t_frame_count;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<340>";
		if(m_no_frames>1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<344>";
			m_frame_ustep=1.0/(m_frame_xstep);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<345>";
			m_frame_vstep=1.0/(m_frame_ystep);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<348>";
			m_u_scale=m_frame_ustep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<349>";
			m_v_scale=m_frame_vstep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<350>";
			m_u_pos=(m_frame_startx)*m_frame_ustep;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<351>";
			m_v_pos=(m_frame_starty)*m_frame_vstep;
		}
		popErr();
	}
	internal var m_bind_flags:int=-1;
	internal static var m_tex_bind_stack:c_TextureStack;
	public static function m_PushBindTexture(t_tex:c_TTexture,t_flags:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<360>";
		dbg_object(t_tex).m_bind_flags=t_flags;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<361>";
		m_tex_bind_stack.p_Push7(t_tex);
		popErr();
		return 0;
	}
	public static function m_LoadAnimTexture(t_file:String,t_flags:int,t_frame_width:int,t_frame_height:int,t_first_frame:int,t_frame_count:int,t_tex:c_TTexture,t_force_new:int):c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<264>";
		if(t_tex==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<264>";
			t_tex=(new c_TTexture).m_TTexture_new();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<266>";
		dbg_object(t_tex).m_file=t_file;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<269>";
		t_tex.p_FilterFlags();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<270>";
		if(t_flags>-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<270>";
			dbg_object(t_tex).m_flags=t_flags;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<274>";
		var t_old_tex:c_TTexture=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<275>";
		if(!((t_force_new)!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<275>";
			t_old_tex=t_tex.p_TexInList();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<277>";
		if(t_old_tex!=null && t_old_tex!=t_tex){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<279>";
			popErr();
			return t_old_tex;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<281>";
			if(t_old_tex!=t_tex){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<282>";
				dbg_object(t_tex).m_tex_link=m_tex_list.p_AddLast9(t_tex);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<287>";
		var t_new_scx:Number=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<287>";
		var t_new_scy:Number=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<287>";
		var t_oldw:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<287>";
		var t_oldh:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<289>";
		dbg_object(t_tex).m_pixmap=c_TPixmap.m_LoadPixmap(t_file);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<290>";
		if(dbg_object(dbg_object(t_tex).m_pixmap).m_height==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<290>";
			popErr();
			return t_tex;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<292>";
		t_oldw=dbg_object(dbg_object(t_tex).m_pixmap).m_width;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<292>";
		t_oldh=dbg_object(dbg_object(t_tex).m_pixmap).m_height;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<293>";
		dbg_object(t_tex).m_orig_width=t_oldw;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<293>";
		dbg_object(t_tex).m_orig_height=t_oldh;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<295>";
		if((dbg_object(t_tex).m_flags&256)==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<296>";
			dbg_object(t_tex).m_pixmap=m_AdjustPixmap(dbg_object(t_tex).m_pixmap,dbg_object(t_tex).m_resize_smooth,t_tex);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<299>";
		dbg_object(t_tex).m_width=dbg_object(dbg_object(t_tex).m_pixmap).m_width;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<300>";
		dbg_object(t_tex).m_height=dbg_object(dbg_object(t_tex).m_pixmap).m_height;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<302>";
		if(t_oldw!=dbg_object(t_tex).m_width || t_oldh!=dbg_object(t_tex).m_height){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<303>";
			t_new_scx=(dbg_object(t_tex).m_width)/(t_oldw);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<304>";
			t_new_scy=(dbg_object(t_tex).m_height)/(t_oldh);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<308>";
		if(t_frame_width==0 && t_frame_height==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<309>";
			t_frame_width=dbg_object(dbg_object(t_tex).m_pixmap).m_width;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<310>";
			t_frame_height=dbg_object(dbg_object(t_tex).m_pixmap).m_height;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<313>";
			t_frame_width=(((t_frame_width)*t_new_scx)|0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<314>";
			t_frame_height=(((t_frame_height)*t_new_scy)|0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<317>";
		t_tex.p_SetAnimationFrames(t_first_frame,t_frame_count,t_frame_width,t_frame_height);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<320>";
		m_PushBindTexture(t_tex,t_flags);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<322>";
		popErr();
		return t_tex;
	}
	public static function m_LoadTexture(t_file:String,t_flags:int,t_tex:c_TTexture):c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<217>";
		var t_:c_TTexture=m_LoadAnimTexture(t_file,t_flags,0,0,0,1,t_tex,0);
		popErr();
		return t_;
	}
	public static function m_LoadTexture2(t_pixmap:c_TPixmap,t_flags:int,t_tex:c_TTexture):c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<224>";
		if(!((t_tex)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<225>";
			t_tex=(new c_TTexture).m_TTexture_new();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<226>";
			dbg_object(t_tex).m_tex_link=m_tex_list.p_AddLast9(t_tex);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<229>";
		t_tex.p_FilterFlags();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<230>";
		if(t_flags>-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<230>";
			dbg_object(t_tex).m_flags=t_flags;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<233>";
		if(t_pixmap==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<233>";
			popErr();
			return t_tex;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<234>";
		dbg_object(t_tex).m_pixmap=t_pixmap;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<235>";
		if(dbg_object(dbg_object(t_tex).m_pixmap).m_height==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<235>";
			popErr();
			return t_tex;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<239>";
		if((dbg_object(t_tex).m_flags&256)==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<240>";
			dbg_object(t_tex).m_pixmap=m_AdjustPixmap(dbg_object(t_tex).m_pixmap,dbg_object(t_tex).m_resize_smooth,t_tex);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<243>";
		dbg_object(t_tex).m_width=dbg_object(dbg_object(t_tex).m_pixmap).m_width;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<244>";
		dbg_object(t_tex).m_height=dbg_object(dbg_object(t_tex).m_pixmap).m_height;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<246>";
		m_PushBindTexture(t_tex,t_flags);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<248>";
		popErr();
		return t_tex;
	}
	internal var m_is_font:Boolean=false;
	internal var m_blend:int=2;
	public function p_TextureBlend(t_blend_no:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<554>";
		m_blend=t_blend_no;
		popErr();
		return 0;
	}
	internal var m_gltex:Array=new_number_array(1);
	public function p_FreeTexture_():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<101>";
		m_tex_link.p_Remove();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<102>";
		if((m_pixmap)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<105>";
			m_pixmap.p_DecBind();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<106>";
			if(m_pixmap.p_GetBindCount()==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<107>";
				c_TPixmap.m_preloader.p_RemoveFromStack(m_file);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<108>";
				m_pixmap.p_FreePixmap();
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<113>";
		dbg_array(m_gltex,0)[dbg_index]=0;
		popErr();
		return 0;
	}
	internal var m_freeMemoryAfterBind:Boolean=false;
	internal var m_coords:int=0;
	internal var m_angle:Number=.0;
	internal var m_cube_mode:int=1;
	internal var m_tex_smooth:Boolean=true;
	internal var m_tex_id:int=0;
	public static function m_TextureFilter(t_match_text:String,t_flags:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<623>";
		var t_filter:c_TTextureFilter=(new c_TTextureFilter).m_TTextureFilter_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<624>";
		dbg_object(t_filter).m_text=t_match_text;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<625>";
		dbg_object(t_filter).m_flags=t_flags;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<627>";
		c_TTextureFilter.m_filter_list.p_AddLast8(t_filter);
		popErr();
		return 0;
	}
	public static function m_CreateTexture(t_width:int,t_height:int,t_flags:int,t_frames:int,t_tex:c_TTexture):c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<182>";
		if(t_tex==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<183>";
			t_tex=(new c_TTexture).m_TTexture_new();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<184>";
			dbg_object(t_tex).m_tex_link=m_tex_list.p_AddLast9(t_tex);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<187>";
		t_width=m_Pow2Size(t_width);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<188>";
		t_height=m_Pow2Size(t_height);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<189>";
		dbg_object(t_tex).m_pixmap=c_TPixmap.m_CreatePixmap(t_width*t_frames,t_height,4);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<191>";
		dbg_object(t_tex).m_flags=t_flags;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<194>";
		dbg_object(t_tex).m_no_frames=t_frames;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<195>";
		dbg_object(t_tex).m_gltex=dbg_object(t_tex).m_gltex.slice(0,dbg_object(t_tex).m_no_frames);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<198>";
		var t_pixmap:c_TPixmap=dbg_object(t_tex).m_pixmap;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<200>";
		if((dbg_object(t_tex).m_flags&256)==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<201>";
			t_pixmap=m_AdjustPixmap(t_pixmap,dbg_object(t_tex).m_resize_smooth,t_tex);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<203>";
		dbg_object(t_tex).m_width=dbg_object(t_pixmap).m_width;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<204>";
		dbg_object(t_tex).m_height=dbg_object(t_pixmap).m_height;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<205>";
		dbg_object(t_tex).m_orig_width=dbg_object(t_tex).m_width;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<206>";
		dbg_object(t_tex).m_orig_height=dbg_object(t_tex).m_height;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<208>";
		m_PushBindTexture(t_tex,t_flags);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<210>";
		popErr();
		return t_tex;
	}
	internal var m_no_mipmaps:int=0;
	public function p_ResizeNoSmooth():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<737>";
		m_resize_smooth=false;
		popErr();
		return 0;
	}
	public function p_FreeTexture():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<95>";
		m_PushBindTexture(this,-255);
		popErr();
		return 0;
	}
}
class c_TSurface extends Object{
	public function m_TSurface_new():c_TSurface{
		pushErr();
		popErr();
		return this;
	}
	internal var m_brush:c_TBrush=(new c_TBrush).m_TBrush_new();
	internal var m_surf_id:int=0;
	internal var m_no_verts:int=0;
	internal var m_no_tris:int=0;
	internal var m_vbo_dyn:Boolean=false;
	internal var m_vert_array_size:int=1;
	internal var m_vert_data:c_VertexDataBuffer=(new c_VertexDataBuffer).m_VertexDataBuffer_new();
	public function p_AddVertex(t_x:Number,t_y:Number,t_z:Number,t_u:Number,t_v:Number,t_w:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<238>";
		m_no_verts=m_no_verts+1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<241>";
		if(m_no_verts>=m_vert_array_size){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<243>";
			do{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<244>";
				m_vert_array_size=m_vert_array_size+512;
			}while(!(m_vert_array_size>m_no_verts));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<247>";
			var t_vas:int=m_vert_array_size;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<249>";
			m_vert_data=bb_monkeybuffer_CopyDataBuffer2(m_vert_data,c_VertexDataBuffer.m_Create(t_vas));
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<256>";
		var t_vid:int=m_no_verts-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<266>";
		var t_data:Array=[t_x,t_y,-t_z,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,t_u,t_v,t_u,t_v];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<267>";
		m_vert_data.p_PokeFloatArray(t_vid,t_data,-1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<269>";
		popErr();
		return t_vid;
	}
	public function p_AddVertex2(t_data:Array,t_len:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<277>";
		if(t_len==-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<277>";
			t_len=t_data.length;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<279>";
		var t_total:int=t_len>>4;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<280>";
		var t_vid:int=m_no_verts;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<281>";
		m_no_verts=m_no_verts+t_total;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<284>";
		if(m_no_verts>=m_vert_array_size){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<286>";
			do{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<287>";
				m_vert_array_size=m_vert_array_size+512;
			}while(!(m_vert_array_size>m_no_verts));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<290>";
			var t_vas:int=m_vert_array_size;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<292>";
			m_vert_data=bb_monkeybuffer_CopyDataBuffer2(m_vert_data,c_VertexDataBuffer.m_Create(t_vas));
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<297>";
		m_vert_data.p_PokeFloatArray(t_vid,t_data,t_len);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<298>";
		var t_:int=t_vid+(t_total-1);
		popErr();
		return t_;
	}
	internal var m_tri_array_size:int=1;
	internal var m_tris:c_ShortBuffer=(new c_ShortBuffer).m_ShortBuffer_new();
	internal var m_reset_vbo:int=-1;
	public function p_AddTriangle(t_v0:int,t_v1:int,t_v2:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<303>";
		m_no_tris=m_no_tris+1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<307>";
		if(m_no_tris>=m_tri_array_size){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<309>";
			do{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<310>";
				m_tri_array_size=m_tri_array_size+512;
			}while(!(m_tri_array_size>m_no_tris));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<313>";
			var t_tas:int=m_tri_array_size;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<315>";
			m_tris=bb_monkeybuffer_CopyShortBuffer(m_tris,c_ShortBuffer.m_Create(t_tas*3));
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<319>";
		var t_v0i:int=m_no_tris*3-3;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<320>";
		var t_v1i:int=m_no_tris*3-2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<321>";
		var t_v2i:int=m_no_tris*3-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<327>";
		m_tris.p_Poke(t_v0i,[t_v2,t_v1,t_v0],-1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<331>";
		m_reset_vbo=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<333>";
		popErr();
		return m_no_tris;
	}
	public function p_AddTriangle2(t_arr:Array,t_len:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<339>";
		if(t_len==-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<339>";
			t_len=t_arr.length;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<341>";
		var t_t0:int=m_no_tris*3;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<342>";
		m_no_tris=m_no_tris+((t_len/3)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<346>";
		if(m_no_tris>=m_tri_array_size){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<348>";
			do{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<349>";
				m_tri_array_size=m_tri_array_size+512;
			}while(!(m_tri_array_size>m_no_tris));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<352>";
			var t_tas:int=m_tri_array_size;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<354>";
			m_tris=bb_monkeybuffer_CopyShortBuffer(m_tris,c_ShortBuffer.m_Create(t_tas*3));
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<359>";
		var t_temp:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<360>";
		for(var t_t:int=0;t_t<=t_len-1;t_t=t_t+3){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<361>";
			t_temp=dbg_array(t_arr,t_t)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<362>";
			dbg_array(t_arr,t_t)[dbg_index]=dbg_array(t_arr,t_t+2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<363>";
			dbg_array(t_arr,t_t+2)[dbg_index]=t_temp;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<366>";
		m_tris.p_Poke(t_t0,t_arr,t_len);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<370>";
		m_reset_vbo=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<372>";
		popErr();
		return m_no_tris;
	}
	public function p_TriangleVertex(t_tri_no:int,t_corner:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<526>";
		var t_:int=m_tris.p_Peek(t_tri_no*3+(2-t_corner));
		popErr();
		return t_;
	}
	public function p_UpdateNormals(t_create_only:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<536>";
		var t_norm_map:c_NormMap=(new c_NormMap).m_NormMap_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<538>";
		for(var t_t:int=0;t_t<=m_no_tris-1;t_t=t_t+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<540>";
			var t_tri_no:int=(t_t+1)*3;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<542>";
			var t_v0:int=m_tris.p_Peek(t_tri_no-3);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<543>";
			var t_v1:int=m_tris.p_Peek(t_tri_no-2);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<544>";
			var t_v2:int=m_tris.p_Peek(t_tri_no-1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<546>";
			var t_ax:Number=m_vert_data.p_VertexX(t_v1)-m_vert_data.p_VertexX(t_v0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<547>";
			var t_ay:Number=m_vert_data.p_VertexY(t_v1)-m_vert_data.p_VertexY(t_v0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<548>";
			var t_az:Number=m_vert_data.p_VertexZ(t_v1)-m_vert_data.p_VertexZ(t_v0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<550>";
			var t_bx:Number=m_vert_data.p_VertexX(t_v2)-m_vert_data.p_VertexX(t_v1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<551>";
			var t_by:Number=m_vert_data.p_VertexY(t_v2)-m_vert_data.p_VertexY(t_v1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<552>";
			var t_bz:Number=m_vert_data.p_VertexZ(t_v2)-m_vert_data.p_VertexZ(t_v1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<554>";
			var t_nx:Number=t_ay*t_bz-t_az*t_by;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<555>";
			var t_ny:Number=t_az*t_bx-t_ax*t_bz;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<556>";
			var t_nz:Number=t_ax*t_by-t_ay*t_bx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<558>";
			var t_norm:c_Vector=(new c_Vector).m_Vector_new(t_nx,t_ny,t_nz);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<559>";
			var t_vnorm:c_Vector=null;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<559>";
			var t_vx:c_Vector=null;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<559>";
			var t_new_norm:c_Vector=null;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<559>";
			var t_vhelper:c_NormHelperClass=null;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<561>";
			for(var t_c:int=0;t_c<=2;t_c=t_c+1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<563>";
				var t_v:int=this.p_TriangleVertex(t_t,t_c);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<565>";
				t_vx=m_vert_data.p_PeekVertCoords(t_v);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<567>";
				t_vhelper=t_norm_map.p_Get(t_vx);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<570>";
				if(!((t_vhelper)!=null)){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<571>";
					t_vhelper=(new c_NormHelperClass).m_NormHelperClass_new();
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<572>";
					dbg_object(t_vhelper).m_vec=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<573>";
					dbg_object(t_vhelper).m_vert=t_v;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<577>";
				dbg_object(t_vhelper).m_vec=t_norm.p_Add(dbg_object(t_vhelper).m_vec);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<579>";
				if(!t_create_only){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<580>";
					t_norm_map.p_Set2(t_vx,t_vhelper);
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<590>";
		for(var t_v3:int=0;t_v3<=m_no_verts-1;t_v3=t_v3+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<591>";
			var t_vx2:c_Vector=m_vert_data.p_PeekVertCoords(t_v3);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<593>";
			var t_norm2:c_NormHelperClass=t_norm_map.p_Get(t_vx2);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<596>";
			if((t_norm2)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<597>";
				dbg_object(t_norm2).m_vec=dbg_object(t_norm2).m_vec.p_Normalize();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<599>";
				m_vert_data.p_PokeNormals(t_v3,dbg_object(dbg_object(t_norm2).m_vec).m_x,dbg_object(dbg_object(t_norm2).m_vec).m_y,dbg_object(dbg_object(t_norm2).m_vec).m_z);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<605>";
		m_reset_vbo=m_reset_vbo|4;
		popErr();
		return 0;
	}
	public function p_ClearSurface(t_clear_verts:Boolean,t_clear_tris:Boolean,t_keep_array:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<190>";
		if(t_clear_verts){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<192>";
			m_no_verts=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<194>";
			if(!t_keep_array){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<195>";
				m_vert_data=c_VertexDataBuffer.m_Create(0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<196>";
				m_vert_array_size=1;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<201>";
		if(t_clear_tris){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<203>";
			m_no_tris=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<205>";
			if(!t_keep_array){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<206>";
				m_tris=c_ShortBuffer.m_Create(0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<207>";
				m_tri_array_size=1;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<213>";
		m_reset_vbo=-1;
		popErr();
		return 0;
	}
	public function p_VertexTexCoords(t_vid:int,t_u:Number,t_v:Number,t_w:Number,t_coord_set:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<427>";
		if(t_coord_set==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<429>";
			m_vert_data.p_PokeTexCoords0(t_vid,t_u,t_v);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<431>";
			if(t_coord_set==1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<433>";
				m_vert_data.p_PokeTexCoords1(t_vid,t_u,t_v);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<438>";
		m_reset_vbo=m_reset_vbo|2;
		popErr();
		return 0;
	}
	public function p_CropSurfaceBuffers():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<222>";
		if(m_no_verts<1 && m_no_tris<1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<222>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<224>";
		m_vert_data=bb_monkeybuffer_CopyDataBuffer2(m_vert_data,c_VertexDataBuffer.m_Create(m_no_verts));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<226>";
		m_tris=bb_monkeybuffer_CopyShortBuffer(m_tris,c_ShortBuffer.m_Create(m_no_tris*3));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<228>";
		m_vert_array_size=m_no_verts;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<229>";
		m_tri_array_size=m_no_tris;
		popErr();
		return 0;
	}
	public function p_VertexNormal(t_vid:int,t_nx:Number,t_ny:Number,t_nz:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<418>";
		m_vert_data.p_PokeNormals(t_vid,t_nx,t_ny,-t_nz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<421>";
		m_reset_vbo=m_reset_vbo|4;
		popErr();
		return 0;
	}
	public function p_VertexCoords(t_vid:int,t_x:Number,t_y:Number,t_z:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<391>";
		m_vert_data.p_PokeVertCoords(t_vid,t_x,t_y,-t_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<394>";
		m_reset_vbo=m_reset_vbo|1;
		popErr();
		return 0;
	}
	internal var m_vert_bone1_no:Array=[];
	internal var m_vert_weight1:Array=[];
	internal var m_vert_bone2_no:Array=[];
	internal var m_vert_weight2:Array=[];
	internal var m_vert_bone3_no:Array=[];
	internal var m_vert_weight3:Array=[];
	internal var m_vert_bone4_no:Array=[];
	internal var m_vert_weight4:Array=[];
	internal var m_vert_anim:Array=[];
	internal var m_alpha_enable:Boolean=false;
	internal var m_vbo_id:Array=[0,0,0,0,0,0,0];
	internal var m_anim_frame:int=0;
	public function p_VertexColor(t_vid:int,t_r:Number,t_g:Number,t_b:Number,t_a:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<400>";
		m_vert_data.p_PokeColor(t_vid,t_r*0.0039215686274509803,t_g*0.0039215686274509803,t_b*0.0039215686274509803,t_a);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<403>";
		m_reset_vbo=m_reset_vbo|8;
		popErr();
		return 0;
	}
	public function p_PaintSurface(t_bru:c_TBrush):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<163>";
		if(m_brush==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<163>";
			m_brush=(new c_TBrush).m_TBrush_new();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<165>";
		dbg_object(m_brush).m_no_texs=dbg_object(t_bru).m_no_texs;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<166>";
		dbg_object(m_brush).m_name=dbg_object(t_bru).m_name;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<167>";
		dbg_object(m_brush).m_red=dbg_object(t_bru).m_red;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<168>";
		dbg_object(m_brush).m_green=dbg_object(t_bru).m_green;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<169>";
		dbg_object(m_brush).m_blue=dbg_object(t_bru).m_blue;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<170>";
		dbg_object(m_brush).m_alpha=dbg_object(t_bru).m_alpha;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<171>";
		dbg_object(m_brush).m_shine=dbg_object(t_bru).m_shine;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<172>";
		dbg_object(m_brush).m_blend=dbg_object(t_bru).m_blend;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<173>";
		dbg_object(m_brush).m_fx=dbg_object(t_bru).m_fx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<175>";
		for(var t_i:int=0;t_i<=7;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<176>";
			dbg_array(dbg_object(m_brush).m_tex,t_i)[dbg_index]=dbg_array(dbg_object(t_bru).m_tex,t_i)[dbg_index];
		}
		popErr();
		return 0;
	}
	public function p_PaintSurface2(t_tex:c_TTexture,t_index:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<182>";
		if(m_brush==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<182>";
			m_brush=(new c_TBrush).m_TBrush_new();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<183>";
		dbg_object(m_brush).m_no_texs=bb_math_Max(dbg_object(m_brush).m_no_texs,t_index+1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<184>";
		dbg_array(dbg_object(m_brush).m_tex,t_index)[dbg_index]=t_tex;
		popErr();
		return 0;
	}
}
class c_List2 extends Object{
	public function m_List_new():c_List2{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node3=((new c_HeadNode2).m_HeadNode_new());
	public function p_AddLast2(t_data:c_TSurface):c_Node3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node3=(new c_Node3).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TSurface=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast2(t_t);
		}
		popErr();
		return this;
	}
	public function p_Clear():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<36>";
		dbg_object(m__head).m__succ=m__head;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<37>";
		dbg_object(m__head).m__pred=m__head;
		popErr();
		return 0;
	}
	public function p_ObjectEnumerator():c_Enumerator6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator6=(new c_Enumerator6).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_Node3 extends Object{
	internal var m__succ:c_Node3=null;
	internal var m__pred:c_Node3=null;
	internal var m__data:c_TSurface=null;
	public function m_Node_new(t_succ:c_Node3,t_pred:c_Node3,t_data:c_TSurface):c_Node3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode2 extends c_Node3{
	public function m_HeadNode_new():c_HeadNode2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_TColTree extends Object{
	public function m_TColTree_new():c_TColTree{
		pushErr();
		popErr();
		return this;
	}
	internal var m_reset_col_tree:int=0;
	internal var m_divSphere_p:Array=new_object_array(1);
	internal var m_divSphere_r:Array=new_number_array(1);
	internal var m_collider_tree:c_MeshCollider=null;
	public function p_CreateMeshTree(t_mesh:c_TMesh,t_max_tris:int):c_MeshCollider{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<59>";
		if(m_reset_col_tree==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<61>";
			if(m_collider_tree!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<62>";
				m_collider_tree=null;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<64>";
			m_reset_col_tree=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<68>";
		if(m_collider_tree==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<71>";
			var t_total_verts_count:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<72>";
			var t_vindex:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<73>";
			var t_triindex:int=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<76>";
			var t_total_tris:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<76>";
			var t_total_verts:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<78>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<78>";
			var t_:c_Enumerator6=dbg_object(t_mesh).m_surf_list.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<78>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<78>";
				var t_surf:c_TSurface=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<79>";
				t_total_tris+=dbg_object(t_surf).m_no_tris;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<80>";
				t_total_verts+=dbg_object(t_surf).m_no_verts;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<85>";
			m_collider_tree=(new c_MeshCollider).m_MeshCollider_new(t_total_verts,t_total_tris+1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<88>";
			var t_s:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<89>";
			var t_temp_vec0:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<90>";
			var t_temp_vec1:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<91>";
			var t_temp_vec2:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<92>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<92>";
			var t_2:c_Enumerator6=dbg_object(t_mesh).m_surf_list.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<92>";
			while(t_2.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<92>";
				var t_surf2:c_TSurface=t_2.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<94>";
				t_s+=1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<96>";
				var t_no_tris:int=dbg_object(t_surf2).m_no_tris;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<97>";
				var t_no_verts:int=dbg_object(t_surf2).m_no_verts;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<99>";
				if(t_no_tris!=0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<115>";
					for(var t_i:int=0;t_i<=t_no_tris-1;t_i=t_i+1){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<117>";
						var t_i3:int=t_i*3;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<118>";
						var t_v0:int=dbg_object(t_surf2).m_tris.p_Peek(t_i3+0);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<119>";
						var t_v1:int=dbg_object(t_surf2).m_tris.p_Peek(t_i3+1);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<120>";
						var t_v2:int=dbg_object(t_surf2).m_tris.p_Peek(t_i3+2);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<123>";
						var t_ti:int=t_triindex*3;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<124>";
						dbg_array(dbg_object(m_collider_tree).m_tri_vix,t_ti+0)[dbg_index]=t_v2+t_total_verts_count;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<125>";
						dbg_array(dbg_object(m_collider_tree).m_tri_vix,t_ti+1)[dbg_index]=t_v1+t_total_verts_count;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<126>";
						dbg_array(dbg_object(m_collider_tree).m_tri_vix,t_ti+2)[dbg_index]=t_v0+t_total_verts_count;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<135>";
						dbg_object(t_surf2).m_vert_data.p_GetVertCoords(t_temp_vec0,t_v0);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<135>";
						dbg_object(t_temp_vec0).m_z=-dbg_object(t_temp_vec0).m_z;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<136>";
						dbg_object(t_surf2).m_vert_data.p_GetVertCoords(t_temp_vec1,t_v1);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<136>";
						dbg_object(t_temp_vec1).m_z=-dbg_object(t_temp_vec1).m_z;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<137>";
						dbg_object(t_surf2).m_vert_data.p_GetVertCoords(t_temp_vec2,t_v2);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<137>";
						dbg_object(t_temp_vec2).m_z=-dbg_object(t_temp_vec2).m_z;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<138>";
						dbg_array(dbg_object(m_collider_tree).m_tri_verts,t_v0+t_total_verts_count)[dbg_index]=t_temp_vec0.p_Copy();
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<139>";
						dbg_array(dbg_object(m_collider_tree).m_tri_verts,t_v1+t_total_verts_count)[dbg_index]=t_temp_vec1.p_Copy();
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<140>";
						dbg_array(dbg_object(m_collider_tree).m_tri_verts,t_v2+t_total_verts_count)[dbg_index]=t_temp_vec2.p_Copy();
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<141>";
						dbg_object(dbg_array(dbg_object(m_collider_tree).m_tri_centres,t_triindex)[dbg_index]).m_x=(dbg_object(t_temp_vec0).m_x+dbg_object(t_temp_vec1).m_x+dbg_object(t_temp_vec2).m_x)*0.33333333333333331;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<142>";
						dbg_object(dbg_array(dbg_object(m_collider_tree).m_tri_centres,t_triindex)[dbg_index]).m_y=(dbg_object(t_temp_vec0).m_y+dbg_object(t_temp_vec1).m_y+dbg_object(t_temp_vec2).m_y)*0.33333333333333331;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<143>";
						dbg_object(dbg_array(dbg_object(m_collider_tree).m_tri_centres,t_triindex)[dbg_index]).m_z=(dbg_object(t_temp_vec0).m_z+dbg_object(t_temp_vec1).m_z+dbg_object(t_temp_vec2).m_z)*0.33333333333333331;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<149>";
						dbg_array(dbg_object(m_collider_tree).m_tris,t_triindex)[dbg_index]=t_triindex;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<150>";
						dbg_array(dbg_object(m_collider_tree).m_tri_surface,t_triindex)[dbg_index]=t_s;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<152>";
						dbg_array(dbg_object(m_collider_tree).m_tri_number,t_triindex)[dbg_index]=t_i;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<154>";
						t_vindex+=3;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<155>";
						t_triindex+=1;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<160>";
					t_total_verts_count+=t_no_verts;
				}
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<167>";
			dbg_object(m_collider_tree).m_tree=m_collider_tree.p_CreateNode(dbg_object(m_collider_tree).m_tris,0,t_max_tris);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<168>";
			dbg_object(dbg_object(m_collider_tree).m_tree).m_name=dbg_object(t_mesh).m_classname;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<173>";
		popErr();
		return m_collider_tree;
	}
}
class c_MojoSurface extends EmptyNullClass{
	public function m_MojoSurface_new():c_MojoSurface{
		pushErr();
		popErr();
		return this;
	}
	internal var m_tex:c_TTexture=null;
	internal var m_path:String="";
	public static function m_Create(t_path:String):c_MojoSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<522>";
		var t_s:c_MojoSurface=(new c_MojoSurface).m_MojoSurface_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<523>";
		dbg_object(t_s).m_tex=bb_functions_CreateTexture(0,0,1,1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<524>";
		if(t_path!=""){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<525>";
			dbg_object(t_s).m_path=t_path;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<528>";
		popErr();
		return t_s;
	}
	internal static var m_list:Array;
	internal static var m_isLoading:Boolean;
	internal var m_loaded:int=0;
	public override function Width():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<581>";
		popErr();
		return dbg_object(m_tex).m_orig_width;
	}
	internal var m_xstep:Number=.0;
	public override function Height():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<585>";
		popErr();
		return dbg_object(m_tex).m_orig_height;
	}
	internal var m_ystep:Number=.0;
	public function p_LoadTexture(t_path:String,t_mesh:c_TMesh,t_device:c_MojoEmulationDevice):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<554>";
		m_tex.p_ResizeNoSmooth();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<556>";
		dbg_object(m_tex).m_pixmap.p_ClearBind();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<557>";
		c_TTexture.m_LoadAnimTexture(t_path,3,0,0,0,1,m_tex,1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<561>";
		m_loaded=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<565>";
		m_xstep=1.0/(this.Width());
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<566>";
		m_ystep=1.0/(this.Height());
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<568>";
		var t_:Boolean=m_tex!=null;
		popErr();
		return t_;
	}
	public static function m_PreLoad(t_path:String,t_mesh:c_TMesh,t_device:c_MojoEmulationDevice):c_MojoSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<533>";
		var t_s:c_MojoSurface=m_Create(t_path);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<535>";
		var t_sz:int=m_list.length;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<536>";
		m_list=resize_string_array(m_list,t_sz+1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<537>";
		dbg_array(m_list,t_sz)[dbg_index]=t_path;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<540>";
		m_isLoading=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<543>";
		t_s.p_LoadTexture(t_path,t_mesh,t_device);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<546>";
		popErr();
		return t_s;
	}
	public override function Discard():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<573>";
		if((m_tex)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<573>";
			m_tex.p_FreeTexture();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<575>";
		m_tex=null;
		popErr();
		return 0;
	}
	public override function Loaded():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<588>";
		popErr();
		return m_loaded;
	}
}
class c_List3 extends Object{
	public function m_List_new():c_List3{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node4=((new c_HeadNode3).m_HeadNode_new());
	public function p_AddLast3(t_data:c_TMesh):c_Node4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node4=(new c_Node4).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TMesh=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast3(t_t);
		}
		popErr();
		return this;
	}
	public function p_Clear():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<36>";
		dbg_object(m__head).m__succ=m__head;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<37>";
		dbg_object(m__head).m__pred=m__head;
		popErr();
		return 0;
	}
	public function p_Compare2(t_lhs:c_TMesh,t_rhs:c_TMesh):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<32>";
		error("Unable to compare items");
		popErr();
		return 0;
	}
	public function p_Sort(t_ascending:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<194>";
		var t_ccsgn:int=-1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<195>";
		if((t_ascending)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<195>";
			t_ccsgn=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<196>";
		var t_insize:int=1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<198>";
		do{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<199>";
			var t_merges:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<200>";
			var t_tail:c_Node4=m__head;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<201>";
			var t_p:c_Node4=dbg_object(m__head).m__succ;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<203>";
			while(t_p!=m__head){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<204>";
				t_merges+=1;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<205>";
				var t_q:c_Node4=dbg_object(t_p).m__succ;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<205>";
				var t_qsize:int=t_insize;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<205>";
				var t_psize:int=1;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<207>";
				while(t_psize<t_insize && t_q!=m__head){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<208>";
					t_psize+=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<209>";
					t_q=dbg_object(t_q).m__succ;
				}
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<212>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<213>";
					var t_t:c_Node4=null;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<214>";
					if(((t_psize)!=0) && ((t_qsize)!=0) && t_q!=m__head){
						_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<215>";
						var t_cc:int=this.p_Compare2(dbg_object(t_p).m__data,dbg_object(t_q).m__data)*t_ccsgn;
						_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<216>";
						if(t_cc<=0){
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<217>";
							t_t=t_p;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<218>";
							t_p=dbg_object(t_p).m__succ;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<219>";
							t_psize-=1;
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<221>";
							t_t=t_q;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<222>";
							t_q=dbg_object(t_q).m__succ;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<223>";
							t_qsize-=1;
						}
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<225>";
						if((t_psize)!=0){
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<226>";
							t_t=t_p;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<227>";
							t_p=dbg_object(t_p).m__succ;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<228>";
							t_psize-=1;
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<229>";
							if(((t_qsize)!=0) && t_q!=m__head){
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<230>";
								t_t=t_q;
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<231>";
								t_q=dbg_object(t_q).m__succ;
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<232>";
								t_qsize-=1;
							}else{
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<234>";
								break;
							}
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<236>";
					dbg_object(t_t).m__pred=t_tail;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<237>";
					dbg_object(t_tail).m__succ=t_t;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<238>";
					t_tail=t_t;
				}while(!(false));
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<240>";
				t_p=t_q;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<242>";
			dbg_object(t_tail).m__succ=m__head;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<243>";
			dbg_object(m__head).m__pred=t_tail;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<245>";
			if(t_merges<=1){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<245>";
				popErr();
				return 0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<247>";
			t_insize*=2;
		}while(!(false));
		return 0;
	}
	public function p_ObjectEnumerator():c_Enumerator14{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator14=(new c_Enumerator14).m_Enumerator_new(this);
		popErr();
		return t_;
	}
	public function p_IsEmpty():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<50>";
		var t_:Boolean=dbg_object(m__head).m__succ==m__head;
		popErr();
		return t_;
	}
}
class c_Node4 extends Object{
	internal var m__succ:c_Node4=null;
	internal var m__pred:c_Node4=null;
	internal var m__data:c_TMesh=null;
	public function m_Node_new(t_succ:c_Node4,t_pred:c_Node4,t_data:c_TMesh):c_Node4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode3 extends c_Node4{
	public function m_HeadNode_new():c_HeadNode3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_TPixmap extends Object{
	internal static var m_preloader:c_TPixmapPreloader;
	public static function m_PreLoadPixmap(t_file:Array):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<54>";
		var t_:int=m_preloader.p_PreLoad(t_file);
		popErr();
		return t_;
	}
	internal static var m_manager:c_IPixmapManager;
	public static function m_LoadPixmap(t_f:String):c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<67>";
		var t_:c_TPixmap=m_manager.p_LoadPixmap(t_f);
		popErr();
		return t_;
	}
	internal var m_width:int=0;
	internal var m_height:int=0;
	public function p_ResizePixmapNoSmooth(t_neww:int,t_newh:int):c_TPixmap{
		return null;
	}
	public function p_Copy():c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<47>";
		var t_:c_TPixmap=this.p_ResizePixmapNoSmooth(m_width,m_height);
		popErr();
		return t_;
	}
	public function p_MaskPixmap(t_r:int,t_g:int,t_b:int):void{
		pushErr();
		popErr();
	}
	public function p_ResizePixmap(t_neww:int,t_newh:int):c_TPixmap{
		return null;
	}
	internal var m_bind:int=0;
	public function p_DecBind():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<107>";
		m_bind-=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<108>";
		if(m_bind<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<108>";
			m_bind=0;
		}
		popErr();
	}
	public function p_GetBindCount():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<112>";
		popErr();
		return m_bind;
	}
	public function p_FreePixmap():void{
		return;
	}
	public function m_TPixmap_new():c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<37>";
		popErr();
		return this;
	}
	public static function m_CreatePixmap(t_w:int,t_h:int,t_format:int):c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<72>";
		var t_:c_TPixmap=m_manager.p_CreatePixmap(t_w,t_h,t_format);
		popErr();
		return t_;
	}
	public function p_SetBind():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<103>";
		m_bind+=1;
		popErr();
	}
	public function p_ClearBind():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<116>";
		m_bind=0;
		popErr();
	}
}
class c_TPixmapPreloader extends Object{
	internal var m_manager:c_IPreloadManager=null;
	internal var m_old_file:Array=new_string_array(1);
	internal var m_start_stack:c_Stack2=(new c_Stack2).m_Stack_new();
	internal var m_finish_stack:c_Stack2=(new c_Stack2).m_Stack_new();
	internal var m_total:int=0;
	internal var m_loading:Boolean=false;
	public function p_CheckAllLoaded():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<211>";
		if(m_start_stack.p_IsEmpty()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<211>";
			m_loading=false;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<211>";
			popErr();
			return 1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<212>";
		popErr();
		return 0;
	}
	public function p_PreLoad(t_file:Array):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<228>";
		if(!((m_manager)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<228>";
			error("**ERROR: no preload manager");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<234>";
		if(dbg_array(t_file,0)[dbg_index]!=dbg_array(m_old_file,0)[dbg_index] || dbg_array(t_file,t_file.length-1)[dbg_index]!=dbg_array(m_old_file,m_old_file.length-1)[dbg_index]){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<237>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<237>";
			var t_:Array=t_file;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<237>";
			var t_2:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<237>";
			while(t_2<t_.length){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<237>";
				var t_f:String=dbg_array(t_,t_2)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<237>";
				t_2=t_2+1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<239>";
				if(t_f==""){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<239>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<242>";
				var t_skip:Boolean=false;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<243>";
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<243>";
				var t_3:c_Enumerator=m_start_stack.p_ObjectEnumerator();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<243>";
				while(t_3.p_HasNext()){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<243>";
					var t_ss:c_PixmapStack=t_3.p_NextObject();
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<244>";
					if(dbg_object(t_ss).m_file==t_f){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<244>";
						t_skip=true;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<244>";
						break;
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<246>";
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<246>";
				var t_4:c_Enumerator=m_finish_stack.p_ObjectEnumerator();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<246>";
				while(t_4.p_HasNext()){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<246>";
					var t_ss2:c_PixmapStack=t_4.p_NextObject();
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<247>";
					if(dbg_object(t_ss2).m_file==t_f){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<247>";
						t_skip=true;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<247>";
						break;
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<250>";
				if(t_skip!=true){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<251>";
					m_total+=1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<252>";
					m_start_stack.p_Insert2(0,(new c_PixmapStack).m_PixmapStack_new(t_f,bb_data_FixDataPath(t_f),m_total));
				}
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<257>";
			m_old_file=t_file;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<263>";
		if(!m_start_stack.p_IsEmpty()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<265>";
			m_loading=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<268>";
			var t_f2:c_PixmapStack=null;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<270>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<270>";
			var t_5:c_BackwardsEnumerator=m_start_stack.p_Backwards().p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<270>";
			while(t_5.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<270>";
				t_f2=t_5.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<272>";
				if(dbg_object(t_f2).m_loading==false){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<274>";
					m_manager.p_PreLoadData(dbg_object(t_f2).m_file,dbg_object(t_f2).m_id);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<275>";
					dbg_object(t_f2).m_loading=true;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<276>";
					break;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<279>";
					if(m_manager.p_IsLoaded(dbg_object(t_f2).m_id)){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<281>";
						m_start_stack.p_RemoveEach(t_f2);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<282>";
						m_finish_stack.p_Push4(t_f2);
					}
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<293>";
		var t_6:int=this.p_CheckAllLoaded();
		popErr();
		return t_6;
	}
	public function p_RemoveFromStack(t_file:String):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<323>";
		if(!m_finish_stack.p_IsEmpty()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<325>";
			var t_j:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<326>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<326>";
			var t_:c_Enumerator=m_finish_stack.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<326>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<326>";
				var t_i:c_PixmapStack=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<328>";
				t_j=t_j+1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<329>";
				if(dbg_object(t_i).m_file==t_file || dbg_object(t_i).m_new_file==t_file){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<330>";
					m_finish_stack.p_Remove2(t_j);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<331>";
					break;
				}
			}
		}
		popErr();
	}
	public function m_TPixmapPreloader_new(t_m:c_IPreloadManager):c_TPixmapPreloader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<197>";
		m_manager=t_m;
		popErr();
		return this;
	}
	public function m_TPixmapPreloader_new2():c_TPixmapPreloader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<183>";
		popErr();
		return this;
	}
	public function p_GetID(t_file:String):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<307>";
		if(!m_finish_stack.p_IsEmpty()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<309>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<309>";
			var t_:c_Enumerator=m_finish_stack.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<309>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<309>";
				var t_i:c_PixmapStack=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<311>";
				if(dbg_object(t_i).m_file==t_file || dbg_object(t_i).m_new_file==t_file){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<311>";
					popErr();
					return dbg_object(t_i).m_id;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<317>";
		popErr();
		return 0;
	}
	public function p_GetPixmapPreLoad(t_p:c_TPixmap,t_file:String):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<299>";
		var t_id:int=this.p_GetID(t_file);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<300>";
		m_manager.p_SetPixmapFromID(t_p,t_id,t_file);
		popErr();
	}
}
interface c_IPreloadManager{
	function p_PreLoadData(t_f:String,t_file_id:int):void;
	function p_IsLoaded(t_file_id:int):Boolean;
	function p_SetPixmapFromID(t_pixmap:c_TPixmap,t_file_id:int,t_file:String):void;
}
class c_PixmapStack extends Object{
	internal var m_file:String="";
	internal var m_new_file:String="";
	internal var m_id:int=0;
	public function m_PixmapStack_new(t_f:String,t_nf:String,t_i:int):c_PixmapStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<349>";
		m_file=t_f;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<349>";
		m_new_file=t_nf;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<349>";
		m_id=t_i;
		popErr();
		return this;
	}
	public function m_PixmapStack_new2():c_PixmapStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tpixmap.monkey<342>";
		popErr();
		return this;
	}
	internal var m_loading:Boolean=false;
}
class c_Stack2 extends Object{
	public function m_Stack_new():c_Stack2{
		pushErr();
		popErr();
		return this;
	}
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_Stack_new2(t_data:Array):c_Stack2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<13>";
		dbg_object(this).m_data=t_data.slice(0);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<14>";
		dbg_object(this).m_length=t_data.length;
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_Enumerator{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<184>";
		var t_:c_Enumerator=(new c_Enumerator).m_Enumerator_new(this);
		popErr();
		return t_;
	}
	internal static var m_NIL:c_PixmapStack;
	public function p_Length2(t_newlength:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<41>";
		if(t_newlength<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<42>";
			for(var t_i:int=t_newlength;t_i<m_length;t_i=t_i+1){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<43>";
				dbg_array(m_data,t_i)[dbg_index]=m_NIL;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<45>";
			if(t_newlength>m_data.length){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<46>";
				m_data=resize_object_array(m_data,bb_math_Max(m_length*2+10,t_newlength));
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<48>";
		m_length=t_newlength;
		popErr();
	}
	public function p_Length():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<52>";
		popErr();
		return m_length;
	}
	public function p_Insert2(t_index:int,t_value:c_PixmapStack):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<122>";
		if(m_length==m_data.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<123>";
			m_data=resize_object_array(m_data,m_length*2+10);
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<125>";
		for(var t_i:int=m_length;t_i>t_index;t_i=t_i+-1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<126>";
			dbg_array(m_data,t_i)[dbg_index]=dbg_array(m_data,t_i-1)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<128>";
		dbg_array(m_data,t_index)[dbg_index]=t_value;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<129>";
		m_length+=1;
		popErr();
	}
	public function p_IsEmpty():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<56>";
		var t_:Boolean=m_length==0;
		popErr();
		return t_;
	}
	public function p_Backwards():c_BackwardsStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<188>";
		var t_:c_BackwardsStack=(new c_BackwardsStack).m_BackwardsStack_new(this);
		popErr();
		return t_;
	}
	public function p_Equals(t_lhs:c_PixmapStack,t_rhs:c_PixmapStack):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<26>";
		var t_:Boolean=t_lhs==t_rhs;
		popErr();
		return t_;
	}
	public function p_RemoveEach(t_value:c_PixmapStack):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<151>";
		var t_i:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<151>";
		var t_j:int=m_length;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<152>";
		while(t_i<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<153>";
			if(!this.p_Equals(dbg_array(m_data,t_i)[dbg_index],t_value)){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<154>";
				t_i+=1;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<155>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<157>";
			var t_b:int=t_i;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<157>";
			var t_e:int=t_i+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<158>";
			while(t_e<m_length && this.p_Equals(dbg_array(m_data,t_e)[dbg_index],t_value)){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<159>";
				t_e+=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<161>";
			while(t_e<m_length){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<162>";
				dbg_array(m_data,t_b)[dbg_index]=dbg_array(m_data,t_e)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<163>";
				t_b+=1;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<164>";
				t_e+=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<166>";
			m_length-=t_e-t_b;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<167>";
			t_i+=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<169>";
		t_i=m_length;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<170>";
		while(t_i<t_j){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<171>";
			dbg_array(m_data,t_i)[dbg_index]=m_NIL;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<172>";
			t_i+=1;
		}
		popErr();
	}
	public function p_Push4(t_value:c_PixmapStack):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<67>";
		if(m_length==m_data.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<68>";
			m_data=resize_object_array(m_data,m_length*2+10);
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<70>";
		dbg_array(m_data,m_length)[dbg_index]=t_value;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<71>";
		m_length+=1;
		popErr();
	}
	public function p_Push5(t_values:Array,t_offset:int,t_count:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<79>";
		for(var t_i:int=0;t_i<t_count;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<80>";
			this.p_Push4(dbg_array(t_values,t_offset+t_i)[dbg_index]);
		}
		popErr();
	}
	public function p_Push6(t_values:Array,t_offset:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<75>";
		this.p_Push5(t_values,t_offset,t_values.length-t_offset);
		popErr();
	}
	public function p_Remove2(t_index:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<133>";
		for(var t_i:int=t_index;t_i<m_length-1;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<134>";
			dbg_array(m_data,t_i)[dbg_index]=dbg_array(m_data,t_i+1)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<136>";
		m_length-=1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<137>";
		dbg_array(m_data,m_length)[dbg_index]=m_NIL;
		popErr();
	}
}
class c_Enumerator extends Object{
	internal var m_stack:c_Stack2=null;
	public function m_Enumerator_new(t_stack:c_Stack2):c_Enumerator{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<255>";
		dbg_object(this).m_stack=t_stack;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<252>";
		popErr();
		return this;
	}
	internal var m_index:int=0;
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<259>";
		var t_:Boolean=m_index<m_stack.p_Length();
		popErr();
		return t_;
	}
	public function p_NextObject():c_PixmapStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<263>";
		m_index+=1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<264>";
		var t_:c_PixmapStack=dbg_array(dbg_object(m_stack).m_data,m_index-1)[dbg_index];
		popErr();
		return t_;
	}
}
internal function bb_math_Max(t_x:int,t_y:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<56>";
	if(t_x>t_y){
		_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<56>";
		popErr();
		return t_x;
	}
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<57>";
	popErr();
	return t_y;
}
internal function bb_math_Max2(t_x:Number,t_y:Number):Number{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<83>";
	if(t_x>t_y){
		_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<83>";
		popErr();
		return t_x;
	}
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<84>";
	popErr();
	return t_y;
}
class c_BackwardsStack extends Object{
	internal var m_stack:c_Stack2=null;
	public function m_BackwardsStack_new(t_stack:c_Stack2):c_BackwardsStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<277>";
		dbg_object(this).m_stack=t_stack;
		popErr();
		return this;
	}
	public function m_BackwardsStack_new2():c_BackwardsStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<274>";
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_BackwardsEnumerator{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<281>";
		var t_:c_BackwardsEnumerator=(new c_BackwardsEnumerator).m_BackwardsEnumerator_new(m_stack);
		popErr();
		return t_;
	}
}
class c_BackwardsEnumerator extends Object{
	internal var m_stack:c_Stack2=null;
	internal var m_index:int=0;
	public function m_BackwardsEnumerator_new(t_stack:c_Stack2):c_BackwardsEnumerator{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<293>";
		dbg_object(this).m_stack=t_stack;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<294>";
		m_index=dbg_object(t_stack).m_length;
		popErr();
		return this;
	}
	public function m_BackwardsEnumerator_new2():c_BackwardsEnumerator{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<290>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<298>";
		var t_:Boolean=m_index>0;
		popErr();
		return t_;
	}
	public function p_NextObject():c_PixmapStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<302>";
		m_index-=1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<303>";
		popErr();
		return dbg_array(dbg_object(m_stack).m_data,m_index)[dbg_index];
	}
}
internal function bb_functions_PreLoadPixmap(t_fs:Array):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<1104>";
	var t_:int=c_TPixmap.m_PreLoadPixmap(t_fs);
	popErr();
	return t_;
}
internal function bb_functions_PreLoadPixmap2(t_fs:String):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<1108>";
	var t_:int=c_TPixmap.m_PreLoadPixmap([t_fs]);
	popErr();
	return t_;
}
internal function bb_mojographics_SetMojoEmulation():void{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<30>";
	c_MojoEmulationDevice.m_SetDevice();
	popErr();
}
internal function bb_flash11_SetRender(t_flags:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<43>";
	c_TRender.m_render=((new c_FlashMiniB3D).m_FlashMiniB3D_new());
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<44>";
	c_TRender.m_render.p_GraphicsInit(t_flags);
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<45>";
	bb_mojographics_SetMojoEmulation();
	popErr();
	return 0;
}
var bb_app__updateRate:int;
internal function bb_app_SetUpdateRate(t_hertz:int):void{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<224>";
	bb_app__updateRate=t_hertz;
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<225>";
	bb_app__game.SetUpdateRate(t_hertz);
	popErr();
}
internal function bb_input_KeyHit(t_key:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/input.monkey<44>";
	var t_:int=bb_input_device.p_KeyHit(t_key);
	popErr();
	return t_;
}
class c_DeltaTimer extends Object{
	internal var m_targetfps:Number=60.0;
	internal var m_lastticks:Number=.0;
	public function m_DeltaTimer_new(t_fps:Number):c_DeltaTimer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<139>";
		m_targetfps=t_fps;
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<140>";
		m_lastticks=(bb_app_Millisecs());
		popErr();
		return this;
	}
	public function m_DeltaTimer_new2():c_DeltaTimer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<130>";
		popErr();
		return this;
	}
	internal var m_currentticks:Number=.0;
	internal var m_frametime:Number=.0;
	internal var m_delta:Number=.0;
	public function p_UpdateDelta():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<144>";
		m_currentticks=(bb_app_Millisecs());
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<145>";
		m_frametime=m_currentticks-m_lastticks;
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<146>";
		m_delta=m_frametime/(1000.0/m_targetfps);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/examples/Cal3dTest/cal3dminib3d.monkey<147>";
		m_lastticks=m_currentticks;
		popErr();
	}
}
internal function bb_app_Millisecs():int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<233>";
	var t_:int=bb_app__game.Millisecs();
	popErr();
	return t_;
}
class c_TCamera extends c_TEntity{
	internal var m_frustum:Array=[];
	public function m_TCamera_new():c_TCamera{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<57>";
		super.m_TEntity_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<59>";
		m_frustum=bb_monkeyutility_AllocateFloatArray(6,4);
		popErr();
		return this;
	}
	internal var m_vx:int=0;
	internal var m_vy:int=0;
	internal var m_vwidth:int=0;
	internal var m_vheight:int=0;
	internal var m_zoom:Number=1.0;
	internal var m_inv_zoom:Number=1.0;
	internal var m_fov_y:Number=.0;
	public function p_CameraZoom(t_zoom_val:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<205>";
		m_zoom=t_zoom_val;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<206>";
		m_inv_zoom=1.0/t_zoom_val;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<207>";
		m_fov_y=(Math.atan(1.0/(m_zoom*((m_vwidth)/(m_vheight))))*R2D)*2.0;
		popErr();
		return 0;
	}
	internal var m_aspect:Number=.0;
	internal var m_viewport:Array=new_number_array(4);
	public function p_CameraViewport(t_x:int,t_y:int,t_w:int,t_h:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<145>";
		m_vx=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<146>";
		m_vy=c_TRender.m_height-t_h-t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<147>";
		m_vwidth=t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<148>";
		m_vheight=t_h;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<150>";
		this.p_CameraZoom(m_zoom);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<151>";
		m_aspect=(m_vwidth)/(m_vheight);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<153>";
		dbg_array(m_viewport,0)[dbg_index]=m_vx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<154>";
		dbg_array(m_viewport,1)[dbg_index]=m_vy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<155>";
		dbg_array(m_viewport,2)[dbg_index]=t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<156>";
		dbg_array(m_viewport,3)[dbg_index]=t_h;
		popErr();
		return 0;
	}
	internal static var m_cam_list:c_EntityList2;
	internal var m_cam_link:c_Node5=null;
	public static function m_CreateCamera(t_parent_ent:c_TEntity):c_TCamera{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<120>";
		var t_cam:c_TCamera=(new c_TCamera).m_TCamera_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<122>";
		t_cam.p_CameraViewport(0,0,c_TRender.m_width,c_TRender.m_height);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<124>";
		dbg_object(t_cam).m_classname="Camera";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<125>";
		dbg_object(t_cam).m_name="proj"+String(m_cam_list.p_Count());
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<127>";
		t_cam.p_AddParent(t_parent_ent);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<128>";
		dbg_object(t_cam).m_entity_link=c_TEntity.m_entity_list.p_EntityListAdd(t_cam);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<129>";
		dbg_object(t_cam).m_cam_link=m_cam_list.p_EntityListAdd2(t_cam);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<132>";
		if(dbg_object(t_cam).m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<133>";
			dbg_object(t_cam).m_mat.p_Overwrite(dbg_object(dbg_object(t_cam).m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<134>";
			t_cam.p_UpdateMat(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<136>";
			t_cam.p_UpdateMat(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<139>";
		popErr();
		return t_cam;
	}
	internal var m_cls_r:Number=0.0;
	internal var m_cls_g:Number=0.0;
	internal var m_cls_b:Number=0.0;
	public function p_CameraClsColor(t_r:Number,t_g:Number,t_b:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<183>";
		m_cls_r=t_r/255.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<184>";
		m_cls_g=t_g/255.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<185>";
		m_cls_b=t_b/255.0;
		popErr();
		return 0;
	}
	internal var m_range_near:Number=1.0;
	internal var m_range_far:Number=1000.0;
	internal var m_eyedx:Number=0.0;
	internal var m_focus:Number=1.0;
	internal var m_eyedy:Number=0.0;
	internal var m_proj_mode:int=1;
	internal var m_proj_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal var m_draw2D:int=0;
	internal var m_oldw:int=0;
	internal var m_oldh:int=0;
	internal var m_mod_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal var m_view_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal var m_projview_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	public function p_SetPixelCamera():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<643>";
		if(((m_draw2D)!=0) && m_oldw==m_vwidth && m_oldh==m_vheight){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<643>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<644>";
		m_oldw=m_vwidth;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<644>";
		m_oldh=m_vheight;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<645>";
		m_draw2D=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<647>";
		if(m_name==""){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<647>";
			m_name="pixel";
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<650>";
		var t_left:Number=(m_vx)-(m_vwidth)*0.5;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<651>";
		var t_right:Number=(m_vwidth)+t_left;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<652>";
		var t_bottom:Number=(m_vy)-(m_vheight)/2.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<653>";
		var t_top:Number=(m_vheight)+t_bottom;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<655>";
		var t_near:Number=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<656>";
		var t_far:Number=2.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<658>";
		var t_tx:Number=-(t_right+t_left)/(t_right-t_left);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<659>";
		var t_ty:Number=-(t_top+t_bottom)/(t_top-t_bottom);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<660>";
		var t_tz:Number=-(t_far+t_near)/(t_far-t_near);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<663>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],0)[dbg_index]=2.0/(t_right-t_left);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<664>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],1)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<665>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],2)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<666>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<668>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],0)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<669>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],1)[dbg_index]=2.0/(t_top-t_bottom);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<670>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],2)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<671>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<673>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],0)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<674>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],1)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<675>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],2)[dbg_index]=-2.0/(t_far-t_near);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<676>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<678>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],0)[dbg_index]=t_tx-1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<679>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],1)[dbg_index]=t_ty+1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<680>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],2)[dbg_index]=t_tz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<681>";
		dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],3)[dbg_index]=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<685>";
		m_mod_mat.p_LoadIdentity();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<686>";
		m_mat.p_LoadIdentity();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<687>";
		m_view_mat=m_mod_mat;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<688>";
		m_projview_mat.p_Overwrite(m_proj_mat);
		popErr();
		return 0;
	}
	public function p_accFrustum(t_left_:Number,t_right_:Number,t_bottom:Number,t_top:Number,t_zNear:Number,t_zFar:Number,t_pixdx:Number,t_pixdy:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<488>";
		var t_xwsize:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<488>";
		var t_ywsize:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<489>";
		var t_dx:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<489>";
		var t_dy:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<491>";
		if(((t_pixdx)!=0.0) || ((t_pixdy)!=0.0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<492>";
			t_xwsize=t_right_-t_left_;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<493>";
			t_ywsize=t_top-t_bottom;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<494>";
			t_dx=-(t_pixdx*t_xwsize/(dbg_array(m_viewport,2)[dbg_index])+m_eyedx*t_zNear/m_focus);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<495>";
			t_dy=-(t_pixdy*t_ywsize/(dbg_array(m_viewport,3)[dbg_index])+m_eyedy*t_zNear/m_focus);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<499>";
		if(m_proj_mode==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<501>";
			if(m_name==""){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<501>";
				m_name="perspective";
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<504>";
			t_left_+=t_dx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<504>";
			t_right_+=t_dx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<504>";
			t_bottom+=t_dy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<504>";
			t_top+=t_dy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<505>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],0)[dbg_index]=2.0*t_zNear/(t_right_-t_left_);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<506>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],0)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<507>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],0)[dbg_index]=(t_right_+t_left_)/(t_right_-t_left_);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<508>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],0)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<510>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],1)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<511>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],1)[dbg_index]=2.0*t_zNear/(t_top-t_bottom);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<512>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],1)[dbg_index]=(t_top+t_bottom)/(t_top-t_bottom);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<513>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],1)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<515>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],2)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<516>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],2)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<517>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],2)[dbg_index]=-(t_zFar+t_zNear)/(t_zFar-t_zNear);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<518>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],2)[dbg_index]=-(2.0*t_zFar*t_zNear)/(t_zFar-t_zNear);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<520>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],3)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<521>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],3)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<522>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],3)[dbg_index]=-1.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<523>";
			dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],3)[dbg_index]=0.0;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<525>";
			if(m_proj_mode==2){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<529>";
				if(m_name==""){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<529>";
					m_name="isometric";
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<531>";
				t_left_+=t_dx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<531>";
				t_right_+=t_dx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<531>";
				t_bottom+=t_dy;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<531>";
				t_top+=t_dy;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<532>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],0)[dbg_index]=2.0/(t_right_-t_left_);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<533>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],1)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<534>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],2)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<535>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,0)[dbg_index],3)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<537>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],0)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<538>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],1)[dbg_index]=2.0/(t_top-t_bottom);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<539>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],2)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<540>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,1)[dbg_index],3)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<542>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],0)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<543>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],1)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<544>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],2)[dbg_index]=-2.0/(t_zFar-t_zNear);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<545>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,2)[dbg_index],3)[dbg_index]=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<547>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],0)[dbg_index]=-(t_right_+t_left_)/(t_right_-t_left_);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<548>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],1)[dbg_index]=-(t_top+t_bottom)/(t_top-t_bottom);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<549>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],2)[dbg_index]=-(t_zFar+t_zNear)/(t_zFar-t_zNear);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<550>";
				dbg_array(dbg_array(dbg_object(m_proj_mat).m_grid,3)[dbg_index],3)[dbg_index]=1.0;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<552>";
				if(m_proj_mode==3){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<554>";
					this.p_SetPixelCamera();
				}
			}
		}
		popErr();
		return 0;
	}
	public function p_accPerspective(t_fovy:Number,t_zNear:Number,t_zFar:Number,t_pixdx:Number,t_pixdy:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<471>";
		var t_fov2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<471>";
		var t_left_:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<471>";
		var t_right_:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<471>";
		var t_bottom:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<471>";
		var t_top:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<473>";
		t_fov2=t_fovy*0.5;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<476>";
		t_top=t_zNear/(Math.cos((t_fov2)*D2R)/Math.sin((t_fov2)*D2R));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<477>";
		t_bottom=-t_top;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<478>";
		t_right_=t_top*m_aspect;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<479>";
		t_left_=-t_right_;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<482>";
		this.p_accFrustum(t_left_,t_right_,t_bottom,t_top,t_zNear,t_zFar,t_pixdx,t_pixdy);
		popErr();
		return 0;
	}
	public function p_ExtractFrustum():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<312>";
		var t_clip:Array=m_projview_mat.p_ToArray();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<313>";
		var t_t:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<319>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],0)[dbg_index]=dbg_array(t_clip,3)[dbg_index]-dbg_array(t_clip,0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<320>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],1)[dbg_index]=dbg_array(t_clip,7)[dbg_index]-dbg_array(t_clip,4)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<321>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],2)[dbg_index]=dbg_array(t_clip,11)[dbg_index]-dbg_array(t_clip,8)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<322>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],3)[dbg_index]=dbg_array(t_clip,15)[dbg_index]-dbg_array(t_clip,12)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<325>";
		t_t=1.0/Math.sqrt(dbg_array(dbg_array(m_frustum,0)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(m_frustum,0)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_frustum,0)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(m_frustum,0)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_frustum,0)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(m_frustum,0)[dbg_index],2)[dbg_index]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<326>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],0)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<327>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],1)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<328>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],2)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<329>";
		dbg_array(dbg_array(m_frustum,0)[dbg_index],3)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<332>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],0)[dbg_index]=dbg_array(t_clip,3)[dbg_index]+dbg_array(t_clip,0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<333>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],1)[dbg_index]=dbg_array(t_clip,7)[dbg_index]+dbg_array(t_clip,4)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<334>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],2)[dbg_index]=dbg_array(t_clip,11)[dbg_index]+dbg_array(t_clip,8)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<335>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],3)[dbg_index]=dbg_array(t_clip,15)[dbg_index]+dbg_array(t_clip,12)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<338>";
		t_t=1.0/Math.sqrt(dbg_array(dbg_array(m_frustum,1)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(m_frustum,1)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_frustum,1)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(m_frustum,1)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_frustum,1)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(m_frustum,1)[dbg_index],2)[dbg_index]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<339>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],0)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<340>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],1)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<341>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],2)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<342>";
		dbg_array(dbg_array(m_frustum,1)[dbg_index],3)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<345>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],0)[dbg_index]=dbg_array(t_clip,3)[dbg_index]+dbg_array(t_clip,1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<346>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],1)[dbg_index]=dbg_array(t_clip,7)[dbg_index]+dbg_array(t_clip,5)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<347>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],2)[dbg_index]=dbg_array(t_clip,11)[dbg_index]+dbg_array(t_clip,9)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<348>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],3)[dbg_index]=dbg_array(t_clip,15)[dbg_index]+dbg_array(t_clip,13)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<351>";
		t_t=1.0/Math.sqrt(dbg_array(dbg_array(m_frustum,2)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(m_frustum,2)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_frustum,2)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(m_frustum,2)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_frustum,2)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(m_frustum,2)[dbg_index],2)[dbg_index]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<352>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],0)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<353>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],1)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<354>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],2)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<355>";
		dbg_array(dbg_array(m_frustum,2)[dbg_index],3)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<358>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],0)[dbg_index]=dbg_array(t_clip,3)[dbg_index]-dbg_array(t_clip,1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<359>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],1)[dbg_index]=dbg_array(t_clip,7)[dbg_index]-dbg_array(t_clip,5)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<360>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],2)[dbg_index]=dbg_array(t_clip,11)[dbg_index]-dbg_array(t_clip,9)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<361>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],3)[dbg_index]=dbg_array(t_clip,15)[dbg_index]-dbg_array(t_clip,13)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<364>";
		t_t=1.0/Math.sqrt(dbg_array(dbg_array(m_frustum,3)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(m_frustum,3)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_frustum,3)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(m_frustum,3)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_frustum,3)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(m_frustum,3)[dbg_index],2)[dbg_index]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<365>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],0)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<366>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],1)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<367>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],2)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<368>";
		dbg_array(dbg_array(m_frustum,3)[dbg_index],3)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<371>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],0)[dbg_index]=dbg_array(t_clip,3)[dbg_index]-dbg_array(t_clip,2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<372>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],1)[dbg_index]=dbg_array(t_clip,7)[dbg_index]-dbg_array(t_clip,6)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<373>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],2)[dbg_index]=dbg_array(t_clip,11)[dbg_index]-dbg_array(t_clip,10)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<374>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],3)[dbg_index]=dbg_array(t_clip,15)[dbg_index]-dbg_array(t_clip,14)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<377>";
		t_t=1.0/Math.sqrt(dbg_array(dbg_array(m_frustum,4)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(m_frustum,4)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_frustum,4)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(m_frustum,4)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_frustum,4)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(m_frustum,4)[dbg_index],2)[dbg_index]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<378>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],0)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<379>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],1)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<380>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],2)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<381>";
		dbg_array(dbg_array(m_frustum,4)[dbg_index],3)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<384>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],0)[dbg_index]=dbg_array(t_clip,3)[dbg_index]+dbg_array(t_clip,2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<385>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],1)[dbg_index]=dbg_array(t_clip,7)[dbg_index]+dbg_array(t_clip,6)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<386>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],2)[dbg_index]=dbg_array(t_clip,11)[dbg_index]+dbg_array(t_clip,10)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<387>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],3)[dbg_index]=dbg_array(t_clip,15)[dbg_index]+dbg_array(t_clip,14)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<390>";
		t_t=1.0/Math.sqrt(dbg_array(dbg_array(m_frustum,5)[dbg_index],0)[dbg_index]*dbg_array(dbg_array(m_frustum,5)[dbg_index],0)[dbg_index]+dbg_array(dbg_array(m_frustum,5)[dbg_index],1)[dbg_index]*dbg_array(dbg_array(m_frustum,5)[dbg_index],1)[dbg_index]+dbg_array(dbg_array(m_frustum,5)[dbg_index],2)[dbg_index]*dbg_array(dbg_array(m_frustum,5)[dbg_index],2)[dbg_index]);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<391>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],0)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<392>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],1)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<393>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],2)[dbg_index]*=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<394>";
		dbg_array(dbg_array(m_frustum,5)[dbg_index],3)[dbg_index]*=t_t;
		popErr();
		return 0;
	}
	public function p_Update2(t_cam:c_TCamera):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<455>";
		this.p_accPerspective(m_fov_y,m_range_near,m_range_far,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<458>";
		m_mod_mat=m_mat.p_Inverse();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<459>";
		if(((m_eyedx)!=0.0) || ((m_eyedy)!=0.0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<459>";
			m_mod_mat.p_Translate(-m_eyedx,-m_eyedy,0.0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<461>";
		m_view_mat=m_mod_mat;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<462>";
		m_projview_mat.p_Overwrite(m_proj_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<463>";
		m_projview_mat.p_Multiply4(m_mod_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<465>";
		if((t_cam)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<465>";
			this.p_ExtractFrustum();
		}
		popErr();
		return 0;
	}
	public function p_EntityInFrustum(t_ent:c_TEntity):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<400>";
		var t_x:Number=t_ent.p_EntityX(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<401>";
		var t_y:Number=t_ent.p_EntityY(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<402>";
		var t_z:Number=t_ent.p_EntityZ(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<404>";
		var t_radius:Number=bb_math_Abs2(dbg_object(t_ent).m_cull_radius);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<407>";
		var t_mesh:c_TMesh=((t_ent) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<408>";
		if((t_mesh)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<411>";
			var t_r:Array=dbg_object(t_ent).m_mat.p_TransformPoint(dbg_object(t_mesh).m_center_x,dbg_object(t_mesh).m_center_y,dbg_object(t_mesh).m_center_z,1.0);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<412>";
			t_x=dbg_array(t_r,0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<412>";
			t_y=dbg_array(t_r,1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<412>";
			t_z=dbg_array(t_r,2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<416>";
			var t_gs:Number=bb_math_Max2(bb_math_Max2(dbg_object(t_ent).m_gsx,dbg_object(t_ent).m_gsy),dbg_object(t_ent).m_gsz);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<417>";
			t_radius=t_radius*t_gs;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<418>";
			if(t_radius<0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<418>";
				t_radius=-t_radius;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<424>";
		var t_d:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<427>";
		t_d=dbg_array(dbg_array(m_frustum,0)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_frustum,0)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_frustum,0)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_frustum,0)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<428>";
		if(t_d<=-t_radius){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<428>";
			popErr();
			return 0.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<429>";
		t_d=dbg_array(dbg_array(m_frustum,1)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_frustum,1)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_frustum,1)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_frustum,1)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<430>";
		if(t_d<=-t_radius){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<430>";
			popErr();
			return 0.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<431>";
		t_d=dbg_array(dbg_array(m_frustum,2)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_frustum,2)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_frustum,2)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_frustum,2)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<432>";
		if(t_d<=-t_radius){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<432>";
			popErr();
			return 0.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<433>";
		t_d=dbg_array(dbg_array(m_frustum,3)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_frustum,3)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_frustum,3)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_frustum,3)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<434>";
		if(t_d<=-t_radius){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<434>";
			popErr();
			return 0.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<435>";
		t_d=dbg_array(dbg_array(m_frustum,4)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_frustum,4)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_frustum,4)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_frustum,4)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<436>";
		if(t_d<=-t_radius){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<436>";
			popErr();
			return 0.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<437>";
		t_d=dbg_array(dbg_array(m_frustum,5)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(m_frustum,5)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(m_frustum,5)[dbg_index],2)[dbg_index]*t_z+dbg_array(dbg_array(m_frustum,5)[dbg_index],3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<438>";
		if(t_d<=-t_radius){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<438>";
			popErr();
			return 0.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<441>";
		var t_:Number=t_d+t_radius;
		popErr();
		return t_;
	}
	internal var m_cls_color:Boolean=true;
	internal var m_cls_zbuffer:Boolean=true;
	public function p_CameraClsMode(t_color:Boolean,t_zbuffer:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<191>";
		m_cls_color=t_color;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<192>";
		m_cls_zbuffer=t_zbuffer;
		popErr();
		return 0;
	}
	internal var m_fog_mode:int=0;
	public function p_CameraScissor(t_x:int,t_y:int,t_w:int,t_h:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<162>";
		if(t_x<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<162>";
			t_x=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<163>";
		if(t_x>c_TRender.m_width){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<163>";
			t_x=c_TRender.m_width;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<164>";
		if(t_y<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<164>";
			t_y=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<165>";
		if(t_y>c_TRender.m_height){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<165>";
			t_y=c_TRender.m_height;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<167>";
		if(t_w<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<167>";
			t_w=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<168>";
		if(t_w>c_TRender.m_width){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<168>";
			t_w=c_TRender.m_width;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<169>";
		if(t_h<0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<169>";
			t_h=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<170>";
		if(t_h>c_TRender.m_height){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<170>";
			t_h=c_TRender.m_height;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<172>";
		t_y=c_TRender.m_height-t_h-t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<174>";
		dbg_array(m_viewport,0)[dbg_index]=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<175>";
		dbg_array(m_viewport,1)[dbg_index]=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<176>";
		dbg_array(m_viewport,2)[dbg_index]=t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcamera.monkey<177>";
		dbg_array(m_viewport,3)[dbg_index]=t_h;
		popErr();
		return 0;
	}
}
internal function bb_monkeyutility_AllocateFloatArray(t_i:int,t_j:int):Array{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeyutility.monkey<18>";
	var t_arr:Array=new_array_array(t_i);
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeyutility.monkey<19>";
	for(var t_ind:int=0;t_ind<t_i;t_ind=t_ind+1){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeyutility.monkey<20>";
		dbg_array(t_arr,t_ind)[dbg_index]=new_number_array(t_j);
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeyutility.monkey<22>";
	popErr();
	return t_arr;
}
class c_List4 extends Object{
	public function m_List_new():c_List4{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node5=((new c_HeadNode4).m_HeadNode_new());
	public function p_AddLast4(t_data:c_TCamera):c_Node5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node5=(new c_Node5).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TCamera=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast4(t_t);
		}
		popErr();
		return this;
	}
	public function p_Count():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<41>";
		var t_n:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<41>";
		var t_node:c_Node5=dbg_object(m__head).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<42>";
		while(t_node!=m__head){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<43>";
			t_node=dbg_object(t_node).m__succ;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<44>";
			t_n+=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<46>";
		popErr();
		return t_n;
	}
	public function p_FirstNode():c_Node5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<62>";
		if(dbg_object(m__head).m__succ!=m__head){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<62>";
			popErr();
			return dbg_object(m__head).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<63>";
		popErr();
		return null;
	}
	public function p_AddFirst2(t_data:c_TCamera):c_Node5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<104>";
		var t_:c_Node5=(new c_Node5).m_Node_new(dbg_object(m__head).m__succ,m__head,t_data);
		popErr();
		return t_;
	}
	public function p_ObjectEnumerator():c_Enumerator11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator11=(new c_Enumerator11).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_EntityList2 extends c_List4{
	public function m_EntityList_new():c_EntityList2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2343>";
		super.m_List_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2343>";
		popErr();
		return this;
	}
	public function p_EntityListAdd2(t_obj:c_TCamera):c_Node5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2349>";
		var t_llink:c_Node5=this.p_FirstNode();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2351>";
		if(dbg_object(t_obj).m_order>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2355>";
			t_llink=this.p_AddFirst2(t_obj);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2357>";
			popErr();
			return t_llink;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2364>";
			t_llink=this.p_AddLast4(t_obj);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tentity.monkey<2366>";
			popErr();
			return t_llink;
		}
		return null;
	}
}
class c_Node5 extends Object{
	internal var m__succ:c_Node5=null;
	internal var m__pred:c_Node5=null;
	internal var m__data:c_TCamera=null;
	public function m_Node_new(t_succ:c_Node5,t_pred:c_Node5,t_data:c_TCamera):c_Node5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode4 extends c_Node5{
	public function m_HeadNode_new():c_HeadNode4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
internal function bb_functions_CreateCamera(t_parent:c_TEntity):c_TCamera{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<433>";
	var t_:c_TCamera=c_TCamera.m_CreateCamera(t_parent);
	popErr();
	return t_;
}
class c_TBone extends c_TEntity{
	internal var m_rest_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal static var m_t_mat:c_Matrix;
	internal var m_mat2:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal static var m_new_mat:c_Matrix;
	internal var m_tform_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal var m_inv_mat:c_Matrix=(new c_Matrix).m_Matrix_new();
	public function p_UpdateMatrix(t_mat0:c_Matrix):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<382>";
		m_loc_mat.p_Overwrite(t_mat0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<383>";
		m_mat2.p_Overwrite(m_loc_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<387>";
		if(m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<389>";
			m_mat.p_Overwrite(dbg_object(m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<390>";
			m_mat.p_Multiply(m_loc_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<393>";
			m_gsx=dbg_object(m_parent).m_gsx*m_sx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<394>";
			m_gsy=dbg_object(m_parent).m_gsy*m_sy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<395>";
			m_gsz=dbg_object(m_parent).m_gsz*m_sz;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<401>";
		if(((dbg_object(this).m_parent) as c_TBone)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<403>";
			m_new_mat.p_Overwrite(dbg_object((m_parent) as c_TBone).m_mat2);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<404>";
			m_new_mat.p_Multiply(m_loc_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<405>";
			m_mat2.p_Overwrite(m_new_mat);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<412>";
		m_tform_mat.p_Overwrite(m_mat2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<413>";
		m_tform_mat.p_Multiply(m_inv_mat);
		popErr();
	}
	public static function m_UpdateNonBoneChild(t_ent_p:c_TEntity):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<137>";
		if(((t_ent_p) as c_TBone)==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<139>";
			m_new_mat.p_Overwrite(dbg_object(dbg_object(t_ent_p).m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<142>";
			if(((t_ent_p) as c_TBone)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<143>";
				dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,3)[dbg_index],2)[dbg_index]=-dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,3)[dbg_index],2)[dbg_index];
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<148>";
			dbg_object(t_ent_p).m_mat.p_Overwrite(m_new_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<149>";
			t_ent_p.p_UpdateMat(false);
		}
		popErr();
	}
	public static function m_UpdateBoneChildren(t_p:c_TEntity):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<158>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<158>";
		var t_:c_Enumerator2=dbg_object(t_p).m_child_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<158>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<158>";
			var t_ent:c_TEntity=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<159>";
			var t_bo:c_TBone=((t_ent) as c_TBone);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<161>";
			if(t_bo!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<163>";
				t_bo.p_UpdateMatrix(dbg_object(t_bo).m_loc_mat);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<167>";
				m_UpdateNonBoneChild(t_ent);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<172>";
			m_UpdateBoneChildren(t_ent);
		}
		popErr();
	}
	public function p_PositionBone(t_x:Number,t_y:Number,t_z:Number,t_glob:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<181>";
		m_px=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<181>";
		m_py=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<181>";
		m_pz=t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<184>";
		m_t_mat.p_Overwrite(m_rest_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<185>";
		m_t_mat.p_Multiply(m_loc_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<187>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],0)[dbg_index]=t_x+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<187>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],1)[dbg_index]=t_y+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<187>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],2)[dbg_index]=t_z+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<191>";
		this.p_UpdateMatrix(m_t_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<194>";
		if(dbg_object(this).m_child_list.p_IsEmpty()!=true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<194>";
			m_UpdateBoneChildren(this);
		}
		popErr();
		return 0;
	}
	public function p_RotateBone(t_x:Number,t_y:Number,t_z:Number,t_glob:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<203>";
		m_rx=-t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<203>";
		m_ry=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<203>";
		m_rz=t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<206>";
		m_t_mat.p_Overwrite(m_rest_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<207>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],0)[dbg_index]=m_px+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<207>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],1)[dbg_index]=m_py+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<207>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],2)[dbg_index]=m_pz+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<209>";
		m_t_mat.p_Rotate(t_x,t_y,t_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<213>";
		this.p_UpdateMatrix(m_t_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<216>";
		if(dbg_object(this).m_child_list.p_IsEmpty()!=true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<216>";
			m_UpdateBoneChildren(this);
		}
		popErr();
		return 0;
	}
	public function p_ScaleBone(t_x:Number,t_y:Number,t_z:Number,t_glob:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<223>";
		m_sx=t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<223>";
		m_sy=t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<223>";
		m_sz=t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<226>";
		m_t_mat.p_Overwrite(m_rest_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<229>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],0)[dbg_index]=m_px+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<229>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],1)[dbg_index]=m_py+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<229>";
		dbg_array(dbg_array(dbg_object(m_t_mat).m_grid,3)[dbg_index],2)[dbg_index]=m_pz+dbg_array(dbg_array(dbg_object(m_rest_mat).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<230>";
		m_t_mat.p_Rotate(m_rx,m_ry,m_rz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<231>";
		m_t_mat.p_Scale(t_x,t_y,t_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<234>";
		this.p_UpdateMatrix(m_t_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<239>";
		m_gsx=dbg_object(m_parent).m_gsx*m_sx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<240>";
		m_gsy=dbg_object(m_parent).m_gsy*m_sy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<241>";
		m_gsz=dbg_object(m_parent).m_gsz*m_sz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<243>";
		if(dbg_object(this).m_child_list.p_IsEmpty()!=true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<243>";
			m_UpdateBoneChildren(this);
		}
		popErr();
		return 0;
	}
	internal var m_kx:Number=.0;
	internal var m_ky:Number=.0;
	internal var m_kz:Number=.0;
	internal var m_keys:c_TAnimationKeys=null;
	internal var m_n_px:Number=.0;
	internal var m_n_py:Number=.0;
	internal var m_n_pz:Number=.0;
	internal var m_kqw:Number=.0;
	internal var m_kqx:Number=.0;
	internal var m_kqy:Number=.0;
	internal var m_kqz:Number=.0;
	internal var m_n_qw:Number=.0;
	internal var m_n_qx:Number=.0;
	internal var m_n_qy:Number=.0;
	internal var m_n_qz:Number=.0;
	public function p_Transform(t_pos:c_Vector,t_quat:c_Quaternion,t_update_children:Boolean):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<345>";
		c_Quaternion.m_QuatToMatrix(dbg_object(t_quat).m_x,dbg_object(t_quat).m_y,dbg_object(t_quat).m_z,dbg_object(t_quat).m_w,m_new_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<347>";
		dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,3)[dbg_index],0)[dbg_index]=dbg_object(t_pos).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<348>";
		dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,3)[dbg_index],1)[dbg_index]=dbg_object(t_pos).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<349>";
		dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,3)[dbg_index],2)[dbg_index]=dbg_object(t_pos).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<352>";
		m_px=dbg_object(t_pos).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<353>";
		m_py=dbg_object(t_pos).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<354>";
		m_pz=dbg_object(t_pos).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<359>";
		var t_mx:Number=dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,2)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<360>";
		var t_my:Number=dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,2)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<361>";
		var t_mz:Number=dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,2)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<362>";
		m_rx=-(Math.atan2(t_mx,t_mz)*R2D);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<363>";
		m_ry=-(Math.atan2(t_my,Math.sqrt(t_mx*t_mx+t_mz*t_mz))*R2D);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<364>";
		m_rz=(Math.atan2(dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,0)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(m_new_mat).m_grid,1)[dbg_index],1)[dbg_index])*R2D);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<367>";
		this.p_UpdateMatrix(m_new_mat);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<371>";
		if(t_update_children){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<372>";
			if(dbg_object(this).m_child_list.p_IsEmpty()!=true){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tbone.monkey<372>";
				c_TEntity.m_UpdateChildren((this),0);
			}
		}
		popErr();
	}
}
class c_Line extends Object{
	internal var m_o:c_Vector=null;
	internal var m_d:c_Vector=null;
	public function m_Line_new():c_Line{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<12>";
		m_o=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<13>";
		m_d=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		popErr();
		return this;
	}
	public function m_Line_new2(t_oo:c_Vector,t_dd:c_Vector):c_Line{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<17>";
		m_o=t_oo.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<18>";
		m_d=t_dd.p_Copy();
		popErr();
		return this;
	}
	public function m_Line_new3(t_ox:Number,t_oy:Number,t_oz:Number,t_dx:Number,t_dy:Number,t_dz:Number):c_Line{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<23>";
		m_o=(new c_Vector).m_Vector_new(t_ox,t_oy,t_oz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<24>";
		m_d=(new c_Vector).m_Vector_new(t_dx,t_dy,t_dz);
		popErr();
		return this;
	}
	public function p_Update3(t_ox:Number,t_oy:Number,t_oz:Number,t_dx:Number,t_dy:Number,t_dz:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<35>";
		dbg_object(m_o).m_x=t_ox;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<35>";
		dbg_object(m_o).m_y=t_oy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<35>";
		dbg_object(m_o).m_z=t_oz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<36>";
		dbg_object(m_d).m_x=t_dx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<36>";
		dbg_object(m_d).m_y=t_dy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<36>";
		dbg_object(m_d).m_z=t_dz;
		popErr();
		return 0;
	}
	public function p_Update4(t_l:c_Line):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<42>";
		dbg_object(m_o).m_x=dbg_object(dbg_object(t_l).m_o).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<42>";
		dbg_object(m_o).m_y=dbg_object(dbg_object(t_l).m_o).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<42>";
		dbg_object(m_o).m_z=dbg_object(dbg_object(t_l).m_o).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<43>";
		dbg_object(m_d).m_x=dbg_object(dbg_object(t_l).m_d).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<43>";
		dbg_object(m_d).m_y=dbg_object(dbg_object(t_l).m_d).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<43>";
		dbg_object(m_d).m_z=dbg_object(dbg_object(t_l).m_d).m_z;
		popErr();
		return 0;
	}
	public function p_Multiply5(t_q:Number):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<59>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(dbg_object(m_o).m_x+dbg_object(m_d).m_x*t_q,dbg_object(m_o).m_y+dbg_object(m_d).m_y*t_q,dbg_object(m_o).m_z+dbg_object(m_d).m_z*t_q);
		popErr();
		return t_;
	}
	public function p_Length():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<69>";
		var t_x:Number=dbg_object(m_o).m_x-dbg_object(m_d).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<70>";
		var t_y:Number=dbg_object(m_o).m_y-dbg_object(m_d).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<71>";
		var t_z:Number=dbg_object(m_o).m_z-dbg_object(m_d).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<72>";
		var t_:Number=Math.sqrt(t_x*t_x+t_y*t_y+t_z*t_z);
		popErr();
		return t_;
	}
}
class c_Enumerator2 extends Object{
	internal var m__list:c_List=null;
	internal var m__curr:c_Node2=null;
	public function m_Enumerator_new(t_list:c_List):c_Enumerator2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TEntity=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_TLight extends c_TEntity{
	internal static var m_no_lights:int;
	internal static var m_max_lights:int;
	public function m_TLight_new():c_TLight{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<35>";
		super.m_TEntity_new();
		popErr();
		return this;
	}
	internal var m_light_type:int=0;
	internal static var m_light_list:c_List5;
	internal var m_light_link:c_Node6=null;
	internal var m_const_att:Number=0.5;
	internal var m_lin_att:Number=1.0;
	public static function m_CreateLight(t_l_type:int,t_parent_ent:c_TEntity):c_TLight{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<80>";
		if(m_no_lights>=m_max_lights){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<80>";
			popErr();
			return null;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<82>";
		var t_light:c_TLight=(new c_TLight).m_TLight_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<83>";
		dbg_object(t_light).m_light_type=t_l_type;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<84>";
		dbg_object(t_light).m_classname="Light";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<87>";
		m_no_lights=m_no_lights+1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<91>";
		dbg_object(t_light).m_light_link=m_light_list.p_AddLast5(t_light);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<92>";
		dbg_object(t_light).m_entity_link=c_TEntity.m_entity_list.p_EntityListAdd(t_light);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<93>";
		if((t_parent_ent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<93>";
			t_light.p_AddParent(t_parent_ent);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<95>";
		if(dbg_object(t_light).m_light_type==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<96>";
			dbg_object(t_light).m_const_att=10.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<97>";
			dbg_object(t_light).m_lin_att=10.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<101>";
		if(dbg_object(t_light).m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<102>";
			dbg_object(t_light).m_mat.p_Overwrite(dbg_object(dbg_object(t_light).m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<103>";
			t_light.p_UpdateMat(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<105>";
			t_light.p_UpdateMat(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tlight.monkey<108>";
		popErr();
		return t_light;
	}
	internal static var m_ambient_red:Number;
	internal static var m_ambient_green:Number;
	internal static var m_ambient_blue:Number;
	internal var m_red:Number=1.0;
	internal var m_green:Number=1.0;
	internal var m_blue:Number=1.0;
	internal var m_quad_att:Number=0.0;
	internal var m_actual_range:Number=1000.0;
}
class c_List5 extends Object{
	public function m_List_new():c_List5{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node6=((new c_HeadNode5).m_HeadNode_new());
	public function p_AddLast5(t_data:c_TLight):c_Node6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node6=(new c_Node6).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TLight=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast5(t_t);
		}
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_Enumerator13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator13=(new c_Enumerator13).m_Enumerator_new(this);
		popErr();
		return t_;
	}
	public function p_IsEmpty():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<50>";
		var t_:Boolean=dbg_object(m__head).m__succ==m__head;
		popErr();
		return t_;
	}
	public function p_First():c_TLight{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<73>";
		if(this.p_IsEmpty()){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<73>";
			error("Illegal operation on empty list");
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<75>";
		popErr();
		return dbg_object(dbg_object(m__head).m__succ).m__data;
	}
}
class c_Node6 extends Object{
	internal var m__succ:c_Node6=null;
	internal var m__pred:c_Node6=null;
	internal var m__data:c_TLight=null;
	public function m_Node_new(t_succ:c_Node6,t_pred:c_Node6,t_data:c_TLight):c_Node6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode5 extends c_Node6{
	public function m_HeadNode_new():c_HeadNode5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
internal function bb_functions_CreateLight(t_light_type:int,t_parent:c_TEntity):c_TLight{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<473>";
	var t_:c_TLight=c_TLight.m_CreateLight(t_light_type,t_parent);
	popErr();
	return t_;
}
class c_Cal3dB3d extends Object{
	internal var m_B3dModel:c_TMesh=null;
	internal var m_Meshes:c_List6=null;
	internal var m_Anims:c_List7=null;
	internal var m_CoreModel:CalCoreModel=null;
	public function m_Cal3dB3d_new():c_Cal3dB3d{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<127>";
		m_B3dModel=c_TMesh.m_CreateMesh(null);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<128>";
		m_Meshes=(new c_List6).m_List_new();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<129>";
		m_Anims=(new c_List7).m_List_new();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<131>";
		m_CoreModel=(new CalCoreModel);
		popErr();
		return this;
	}
	internal var m_Skele:CalCoreSkeleton=null;
	public function p_SetSkeleton(t_url:String):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<141>";
		m_Skele=CalLoader.parseXmlCoreSkeleton(bb_app_LoadString(t_url));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<142>";
		if(m_Skele==null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<143>";
			print("Skeleton was Null!!!");
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<145>";
		m_CoreModel.setCoreSkeleton(m_Skele);
		popErr();
		return 0;
	}
	public function p_AddMesh(t_url:String):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<169>";
		var t_msh:CalCoreMesh=null;
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<173>";
		t_msh=CalLoader.parseXmlCoreMesh(bb_app_LoadString(t_url));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<175>";
		if(t_msh!=null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<177>";
			var t_c3db3dm:c_Cal3dB3dMesh=(new c_Cal3dB3dMesh).m_Cal3dB3dMesh_new();
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<178>";
			dbg_object(t_c3db3dm).m_MID=m_CoreModel.addCoreMesh(t_msh);
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<179>";
			print("Added: "+String(dbg_object(t_c3db3dm).m_MID));
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<180>";
			dbg_object(t_c3db3dm).m_CMesh=t_msh;
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<181>";
			dbg_object(t_c3db3dm).m_B3dMesh=c_TMesh.m_CreateMesh(m_B3dModel);
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<182>";
			dbg_object(dbg_object(t_c3db3dm).m_B3dMesh).m_anim=2;
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<183>";
			m_Meshes.p_AddLast6(t_c3db3dm);
		}
		popErr();
		return 0;
	}
	public function p_AddAnim(t_url:String):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<151>";
		if(m_Skele==null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<151>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<152>";
		var t_anm:CalCoreAnimation=null;
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<156>";
		t_anm=CalLoader.parseXmlCoreAnimation(bb_app_LoadString(t_url),m_Skele);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<158>";
		if(t_anm!=null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<160>";
			var t_aa:int=m_CoreModel.addCoreAnimation(t_anm);
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<161>";
			print("Loaded Anim: "+String(t_aa));
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<162>";
			m_Anims.p_AddLast7(t_anm);
		}
		popErr();
		return 0;
	}
	internal var m_CModel:CalModel=null;
	internal var m_cal_renderer:CalRenderer=null;
	public function p_Build():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<190>";
		if(m_CoreModel.getCoreSkeleton()==null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<191>";
			print("Core Skeleton is null!");
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<193>";
		m_CoreModel.getCoreSkeleton().calculateBoundingBoxes(m_CoreModel);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<194>";
		m_CModel=m_CoreModel.makemodel();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<196>";
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<196>";
		var t_:c_Enumerator3=m_Meshes.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<196>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<196>";
			var t_cb3d:c_Cal3dB3dMesh=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<197>";
			m_CModel.attachMesh(dbg_object(t_cb3d).m_MID);
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<202>";
		if(m_CModel!=null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<203>";
			print("Have Cmodel");
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<206>";
		m_cal_renderer=m_CModel.getRenderer();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<207>";
		m_cal_renderer.beginRendering();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<209>";
		var t_mc:int=m_cal_renderer.getMeshCount();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<210>";
		print("Mesh Count: "+String(t_mc));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<211>";
		for(var t_i:int=0;t_i<=t_mc;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<213>";
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<213>";
			var t_2:c_Enumerator3=m_Meshes.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<213>";
			while(t_2.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<213>";
				var t_cb3d2:c_Cal3dB3dMesh=t_2.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<215>";
				if(dbg_object(t_cb3d2).m_MID==t_i){
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<216>";
					print("Got Mesh: "+String(t_i));
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<218>";
					var t_submeshCount:int=m_cal_renderer.getSubmeshCount(t_i);
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<219>";
					print("NOF: Submeshes "+String(t_submeshCount));
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<220>";
					for(var t_ii:int=0;t_ii<=t_submeshCount-1;t_ii=t_ii+1){
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<222>";
						m_cal_renderer.selectMeshSubmesh(dbg_object(t_cb3d2).m_MID,t_ii);
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<224>";
						var t_vertexCount:int=m_cal_renderer.getVertexCount();
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<225>";
						var t_faceCount:int=m_cal_renderer.getFaceCount();
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<227>";
						print("Verts: "+String(t_vertexCount)+" Faces"+String(t_faceCount));
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<237>";
						var t_vertices:Array=[];
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<238>";
						var t_faces:Array=[];
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<239>";
						if(m_cal_renderer==null){
							_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<240>";
							print("Cal render died?");
						}
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<242>";
						t_vertices=m_cal_renderer.getVertices(0);
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<243>";
						t_faces=m_cal_renderer.getFaces();
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<244>";
						t_cb3d2.p_Build2(t_vertices,t_faces);
					}
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<261>";
		m_cal_renderer.endRendering();
		popErr();
		return 0;
	}
	public function p_Update5(t_d:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<269>";
		m_CModel.update(t_d);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<270>";
		m_cal_renderer.beginRendering();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<271>";
		var t_mc:int=m_cal_renderer.getMeshCount();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<272>";
		for(var t_i:int=0;t_i<=t_mc;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<273>";
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<273>";
			var t_:c_Enumerator3=m_Meshes.p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<273>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<273>";
				var t_cb3d:c_Cal3dB3dMesh=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<274>";
				if(dbg_object(t_cb3d).m_MID==t_i){
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<275>";
					var t_submeshCount:int=m_cal_renderer.getSubmeshCount(t_i);
					_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<277>";
					for(var t_ii:int=0;t_ii<=t_submeshCount-1;t_ii=t_ii+1){
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<278>";
						m_cal_renderer.selectMeshSubmesh(dbg_object(t_cb3d).m_MID,t_ii);
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<279>";
						var t_vertexCount:int=m_cal_renderer.getVertexCount();
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<280>";
						var t_faceCount:int=m_cal_renderer.getFaceCount();
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<291>";
						var t_vertices:Array=[];
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<292>";
						var t_faces:Array=[];
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<293>";
						var t_normals:Array=[];
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<294>";
						t_vertices=m_cal_renderer.getVertices(3);
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<295>";
						t_normals=m_cal_renderer.getNormals(3);
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<296>";
						t_faces=m_cal_renderer.getFaces();
						_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<297>";
						t_cb3d.p_Update7(t_ii,t_vertices,t_normals,t_faces);
					}
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<306>";
		m_cal_renderer.endRendering();
		popErr();
		return 0;
	}
}
class c_Cal3dB3dMesh extends Object{
	public function m_Cal3dB3dMesh_new():c_Cal3dB3dMesh{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<5>";
		popErr();
		return this;
	}
	internal var m_MID:int=0;
	internal var m_CMesh:CalCoreMesh=null;
	internal var m_B3dMesh:c_TMesh=null;
	internal var m_surf:Array=new_object_array(0);
	public function p_Build2(t_v:Array,t_f:Array):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<16>";
		if(m_CMesh==null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<16>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<17>";
		if(m_B3dMesh==null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<17>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<18>";
		var t_ind:int=m_surf.length;
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<19>";
		m_surf=resize_object_array(m_surf,m_surf.length+1);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<21>";
		print("Building Surf: "+String(t_ind));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<23>";
		dbg_array(m_surf,t_ind)[dbg_index]=m_B3dMesh.p_CreateSurface(null);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<27>";
		for(var t_i:int=0;t_i<=t_v.length-1;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<28>";
			dbg_array(m_surf,t_ind)[dbg_index].p_AddVertex(dbg_array(t_v,t_i)[dbg_index].getx(),dbg_array(t_v,t_i)[dbg_index].gety(),-dbg_array(t_v,t_i)[dbg_index].getz(),0.0,0.0,0.0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<30>";
		for(var t_t:int=0;t_t<=t_f.length-1;t_t=t_t+1){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<31>";
			if(dbg_array(t_f,t_t)[dbg_index]!=null){
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<33>";
				var t_tt:Array=dbg_array(t_f,t_t)[dbg_index].Get();
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<34>";
				print("Adding: "+String(t_t)+" "+String(dbg_array(t_tt,0)[dbg_index])+" "+String(dbg_array(t_tt,1)[dbg_index])+" "+String(dbg_array(t_tt,2)[dbg_index]));
				_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<35>";
				dbg_array(m_surf,t_ind)[dbg_index].p_AddTriangle(dbg_array(t_tt,0)[dbg_index],dbg_array(t_tt,1)[dbg_index],dbg_array(t_tt,2)[dbg_index]);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<40>";
		dbg_array(m_surf,t_ind)[dbg_index].p_UpdateNormals(false);
		popErr();
		return 0;
	}
	public function p_Build3(t_v:Array,t_f:Array):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<46>";
		if(m_CMesh==null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<46>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<47>";
		if(m_B3dMesh==null){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<47>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<48>";
		var t_ind:int=m_surf.length;
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<49>";
		m_surf=resize_object_array(m_surf,m_surf.length+1);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<51>";
		print("Building Surf: "+String(t_ind));
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<53>";
		dbg_array(m_surf,t_ind)[dbg_index]=m_B3dMesh.p_CreateSurface(null);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<57>";
		for(var t_i:int=0;t_i<=t_v.length-1;t_i=t_i+3){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<58>";
			dbg_array(m_surf,t_ind)[dbg_index].p_AddVertex(dbg_array(t_v,t_i)[dbg_index],dbg_array(t_v,t_i+1)[dbg_index],-dbg_array(t_v,t_i+2)[dbg_index],0.0,0.0,0.0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<60>";
		dbg_array(m_surf,t_ind)[dbg_index].p_AddTriangle2(t_f,-1);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<62>";
		dbg_array(m_surf,t_ind)[dbg_index].p_UpdateNormals(false);
		popErr();
		return 0;
	}
	public function p_Update6(t_si:int,t_v:Array,t_n:Array,t_f:Array):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<68>";
		dbg_array(m_surf,t_si)[dbg_index].p_ClearSurface(true,true,false);
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<74>";
		for(var t_i:int=0;t_i<=t_v.length-1;t_i=t_i+3){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<75>";
			var t_vid:int=dbg_array(m_surf,t_si)[dbg_index].p_AddVertex(dbg_array(t_v,t_i)[dbg_index],dbg_array(t_v,t_i+1)[dbg_index],-dbg_array(t_v,t_i+2)[dbg_index],0.0,0.0,0.0);
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<76>";
			dbg_array(m_surf,t_si)[dbg_index].p_VertexNormal(t_vid,dbg_array(t_n,t_i)[dbg_index],dbg_array(t_n,t_i+1)[dbg_index],-dbg_array(t_n,t_i+2)[dbg_index]);
		}
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<79>";
		dbg_array(m_surf,t_si)[dbg_index].p_AddTriangle2(t_f,-1);
		popErr();
		return 0;
	}
	public function p_Update7(t_si:int,t_v:Array,t_n:Array,t_f:Array):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<93>";
		for(var t_i:int=0;t_i<=t_v.length-1;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/cal3d/calb3d.monkey<94>";
			dbg_array(m_surf,t_si)[dbg_index].p_VertexCoords(t_i,dbg_array(t_v,t_i)[dbg_index].getx(),dbg_array(t_v,t_i)[dbg_index].gety(),-dbg_array(t_v,t_i)[dbg_index].getz());
		}
		popErr();
		return 0;
	}
}
class c_List6 extends Object{
	public function m_List_new():c_List6{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node7=((new c_HeadNode6).m_HeadNode_new());
	public function p_AddLast6(t_data:c_Cal3dB3dMesh):c_Node7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node7=(new c_Node7).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_Cal3dB3dMesh=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast6(t_t);
		}
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_Enumerator3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator3=(new c_Enumerator3).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_Node7 extends Object{
	internal var m__succ:c_Node7=null;
	internal var m__pred:c_Node7=null;
	internal var m__data:c_Cal3dB3dMesh=null;
	public function m_Node_new(t_succ:c_Node7,t_pred:c_Node7,t_data:c_Cal3dB3dMesh):c_Node7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode6 extends c_Node7{
	public function m_HeadNode_new():c_HeadNode6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_List7 extends Object{
	public function m_List_new():c_List7{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node8=((new c_HeadNode7).m_HeadNode_new());
	public function p_AddLast7(t_data:CalCoreAnimation):c_Node8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node8=(new c_Node8).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:CalCoreAnimation=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast7(t_t);
		}
		popErr();
		return this;
	}
}
class c_Node8 extends Object{
	internal var m__succ:c_Node8=null;
	internal var m__pred:c_Node8=null;
	internal var m__data:CalCoreAnimation=null;
	public function m_Node_new(t_succ:c_Node8,t_pred:c_Node8,t_data:CalCoreAnimation):c_Node8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode7 extends c_Node8{
	public function m_HeadNode_new():c_HeadNode7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
internal function bb_app_LoadString(t_path:String):String{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/app.monkey<220>";
	var t_:String=bb_app__game.LoadString(bb_data_FixDataPath(t_path));
	popErr();
	return t_;
}
class c_Enumerator3 extends Object{
	internal var m__list:c_List6=null;
	internal var m__curr:c_Node7=null;
	public function m_Enumerator_new(t_list:c_List6):c_Enumerator3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_Cal3dB3dMesh{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_Cal3dB3dMesh=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_VertexDataBuffer extends Object{
	public function m_VertexDataBuffer_new():c_VertexDataBuffer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<88>";
		popErr();
		return this;
	}
	internal var m_buf:c_DataBuffer=null;
	public static function m_Create(t_i:int):c_VertexDataBuffer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<111>";
		var t_b:c_VertexDataBuffer=(new c_VertexDataBuffer).m_VertexDataBuffer_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<112>";
		dbg_object(t_b).m_buf=bb_monkeybuffer_CreateDataBuffer((t_i+1)*64);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<117>";
		Driver3D.DataBufferLittleEndian(dbg_object(t_b).m_buf);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<120>";
		popErr();
		return t_b;
	}
	public function p_PokeFloatArray(t_i:int,t_arr:Array,t_len:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<252>";
		if(t_len==-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<252>";
			t_len=t_arr.length;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<259>";
		for(var t_v:int=0;t_v<=t_len-1;t_v=t_v+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<260>";
			m_buf.PokeFloat(t_i*64+t_v*4,dbg_array(t_arr,t_v)[dbg_index]);
		}
		popErr();
	}
	public function p_VertexX(t_vid:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<191>";
		var t_:Number=m_buf.PeekFloat(t_vid*64+0+0);
		popErr();
		return t_;
	}
	public function p_VertexY(t_vid:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<195>";
		var t_:Number=m_buf.PeekFloat(t_vid*64+0+4);
		popErr();
		return t_;
	}
	public function p_VertexZ(t_vid:int):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<199>";
		var t_:Number=m_buf.PeekFloat(t_vid*64+0+8);
		popErr();
		return t_;
	}
	public function p_PeekVertCoords(t_vid:int):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<203>";
		var t_v:int=t_vid*64+0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<204>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(m_buf.PeekFloat(t_v+0),m_buf.PeekFloat(t_v+4),m_buf.PeekFloat(t_v+8));
		popErr();
		return t_;
	}
	public function p_PokeNormals(t_i:int,t_x:Number,t_y:Number,t_z:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<143>";
		var t_index:int=t_i*64+16;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<144>";
		m_buf.PokeFloat(t_index,t_x);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<145>";
		m_buf.PokeFloat(t_index+4,t_y);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<146>";
		m_buf.PokeFloat(t_index+8,t_z);
		popErr();
		return 0;
	}
	public function p_PokeTexCoords0(t_i:int,t_s0:Number,t_t0:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<165>";
		var t_index:int=t_i*64+48;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<166>";
		m_buf.PokeFloat(t_index,t_s0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<167>";
		m_buf.PokeFloat(t_index+4,t_t0);
		popErr();
		return 0;
	}
	public function p_PokeTexCoords1(t_i:int,t_s1:Number,t_t1:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<171>";
		var t_index:int=t_i*64+48;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<172>";
		m_buf.PokeFloat(t_index+8,t_s1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<173>";
		m_buf.PokeFloat(t_index+12,t_t1);
		popErr();
		return 0;
	}
	public function p_PokeVertCoords(t_i:int,t_x:Number,t_y:Number,t_z:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<129>";
		var t_index:int=t_i*64+0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<130>";
		m_buf.PokeFloat(t_index,t_x);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<131>";
		m_buf.PokeFloat(t_index+4,t_y);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<132>";
		m_buf.PokeFloat(t_index+8,t_z);
		popErr();
		return 0;
	}
	public function p_GetVertCoords(t_vec:c_Vector,t_vid:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<208>";
		var t_v:int=t_vid*64+0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<209>";
		dbg_object(t_vec).m_x=m_buf.PeekFloat(t_v+0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<209>";
		dbg_object(t_vec).m_y=m_buf.PeekFloat(t_v+4);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<209>";
		dbg_object(t_vec).m_z=m_buf.PeekFloat(t_v+8);
		popErr();
	}
	public function p_PokeColor(t_i:int,t_r:Number,t_g:Number,t_b:Number,t_a:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<182>";
		var t_index:int=t_i*64+32;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<183>";
		m_buf.PokeFloat(t_index,t_r);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<184>";
		m_buf.PokeFloat(t_index+4,t_g);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<185>";
		m_buf.PokeFloat(t_index+8,t_b);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<186>";
		m_buf.PokeFloat(t_index+12,t_a);
		popErr();
		return 0;
	}
}
class c_DataBuffer extends BBDataBuffer{
	public function m_DataBuffer_new(t_length:int):c_DataBuffer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/brl/databuffer.monkey<94>";
		if(!this._New(t_length)){
			_errInfo="C:/MonkeyXPro77f/modules/brl/databuffer.monkey<94>";
			error("Allocate DataBuffer failed");
		}
		popErr();
		return this;
	}
	public function m_DataBuffer_new2():c_DataBuffer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/brl/databuffer.monkey<91>";
		popErr();
		return this;
	}
}
internal function bb_monkeybuffer_CreateDataBuffer(t_i:int):c_DataBuffer{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<36>";
	var t_:c_DataBuffer=(new c_DataBuffer).m_DataBuffer_new(t_i);
	popErr();
	return t_;
}
internal function bb_monkeybuffer_GetBufferLength(t_buf:c_DataBuffer):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<39>";
	var t_:int=t_buf.Length();
	popErr();
	return t_;
}
internal function bb_monkeybuffer_CopyDataBuffer(t_src:c_DataBuffer,t_dest:c_DataBuffer):c_DataBuffer{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<294>";
	if(t_src==null){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<294>";
		popErr();
		return t_dest;
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<296>";
	var t_size:int=bb_monkeybuffer_GetBufferLength(t_src);
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<297>";
	if(bb_monkeybuffer_GetBufferLength(t_dest)<t_size){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<297>";
		t_size=bb_monkeybuffer_GetBufferLength(t_dest);
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<299>";
	for(var t_i:int=0;t_i<=t_size-1;t_i=t_i+1){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<300>";
		t_dest.PokeByte(t_i,t_src.PeekByte(t_i));
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<303>";
	popErr();
	return t_dest;
}
internal function bb_monkeybuffer_CopyDataBuffer2(t_src:c_VertexDataBuffer,t_dest:c_VertexDataBuffer):c_VertexDataBuffer{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<308>";
	if(dbg_object(t_src).m_buf==null){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<308>";
		popErr();
		return t_dest;
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<310>";
	var t_size:int=bb_monkeybuffer_GetBufferLength(dbg_object(t_src).m_buf);
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<311>";
	if(bb_monkeybuffer_GetBufferLength(dbg_object(t_dest).m_buf)<t_size){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<311>";
		t_size=bb_monkeybuffer_GetBufferLength(dbg_object(t_dest).m_buf);
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<314>";
	for(var t_i:int=0;t_i<=t_size-1;t_i=t_i+4){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<315>";
		dbg_object(t_dest).m_buf.PokeInt(t_i,dbg_object(t_src).m_buf.PeekInt(t_i));
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<319>";
	popErr();
	return t_dest;
}
internal function bb_monkeybuffer_CopyDataBuffer3(t_src:c_VertexDataBuffer,t_dest:c_VertexDataBuffer,t_begin:int,t_bend:int):c_VertexDataBuffer{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<324>";
	if(dbg_object(t_src).m_buf==null){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<324>";
		popErr();
		return t_dest;
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<326>";
	t_begin*=64;
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<327>";
	t_bend*=64;
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<329>";
	if(t_begin==0 && t_bend==0){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<329>";
		t_bend=bb_monkeybuffer_GetBufferLength(dbg_object(t_src).m_buf)-1;
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<330>";
	if(bb_monkeybuffer_GetBufferLength(dbg_object(t_dest).m_buf)-1<t_bend){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<330>";
		t_bend=bb_monkeybuffer_GetBufferLength(dbg_object(t_dest).m_buf)-1;
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<332>";
	for(var t_i:int=t_begin;t_i<=t_bend;t_i=t_i+4){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<334>";
		dbg_object(t_dest).m_buf.PokeInt(t_i,dbg_object(t_src).m_buf.PeekInt(t_i));
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<337>";
	popErr();
	return t_dest;
}
class c_ShortBuffer extends Object{
	public function m_ShortBuffer_new():c_ShortBuffer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<411>";
		popErr();
		return this;
	}
	internal static var m_i2f:c_DataBuffer;
	internal var m_buf:c_DataBuffer=null;
	public static function m_Create(t_i:int):c_ShortBuffer{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<420>";
		m_i2f=bb_monkeybuffer_CreateDataBuffer(4);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<422>";
		var t_b:c_ShortBuffer=(new c_ShortBuffer).m_ShortBuffer_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<423>";
		dbg_object(t_b).m_buf=bb_monkeybuffer_CreateDataBuffer(t_i*2+1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<428>";
		Driver3D.DataBufferLittleEndian(dbg_object(t_b).m_buf);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<431>";
		popErr();
		return t_b;
	}
	public function p_Length():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<459>";
		var t_:int=(((bb_monkeybuffer_GetBufferLength(m_buf))*0.5)|0);
		popErr();
		return t_;
	}
	public function p_Peek(t_i:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<455>";
		var t_:int=m_buf.PeekShort(t_i*2);
		popErr();
		return t_;
	}
	public function p_Poke(t_i:int,t_arr:Array,t_len:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<435>";
		if(t_len==-1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<435>";
			t_len=t_arr.length;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<442>";
		for(var t_v:int=0;t_v<=t_len-1;t_v=t_v+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<443>";
			m_buf.PokeShort((t_i+t_v)*2,dbg_array(t_arr,t_v)[dbg_index]);
		}
		popErr();
	}
	public function p_Poke2(t_i:int,t_v:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<450>";
		m_buf.PokeShort(t_i*2,t_v);
		popErr();
	}
}
internal function bb_monkeybuffer_CopyShortBuffer(t_src:c_ShortBuffer,t_dest:c_ShortBuffer):c_ShortBuffer{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<504>";
	if(t_src==null || dbg_object(t_src).m_buf==null){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<504>";
		popErr();
		return t_dest;
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<506>";
	var t_size:int=t_src.p_Length();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<507>";
	if(t_dest.p_Length()<t_size){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<507>";
		t_size=t_dest.p_Length();
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<509>";
	for(var t_i:int=0;t_i<=t_size-1;t_i=t_i+1){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<510>";
		t_dest.p_Poke2(t_i,t_src.p_Peek(t_i));
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/monkeybuffer.monkey<513>";
	popErr();
	return t_dest;
}
class c_NormHelperClass extends Object{
	public function m_NormHelperClass_new():c_NormHelperClass{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<978>";
		popErr();
		return this;
	}
	internal var m_vec:c_Vector=null;
	internal var m_vert:int=0;
}
class c_Map2 extends Object{
	public function m_Map_new():c_Map2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<7>";
		popErr();
		return this;
	}
	internal var m_root:c_Node9=null;
	public function p_Compare3(t_lhs:c_Vector,t_rhs:c_Vector):int{
		return 0;
	}
	public function p_FindNode2(t_key:c_Vector):c_Node9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<157>";
		var t_node:c_Node9=m_root;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<159>";
		while((t_node)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<160>";
			var t_cmp:int=this.p_Compare3(t_key,dbg_object(t_node).m_key);
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<161>";
			if(t_cmp>0){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<162>";
				t_node=dbg_object(t_node).m_right;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<163>";
				if(t_cmp<0){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<164>";
					t_node=dbg_object(t_node).m_left;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<166>";
					popErr();
					return t_node;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<169>";
		popErr();
		return t_node;
	}
	public function p_Get(t_key:c_Vector):c_NormHelperClass{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<101>";
		var t_node:c_Node9=this.p_FindNode2(t_key);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<102>";
		if((t_node)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<102>";
			popErr();
			return dbg_object(t_node).m_value;
		}
		popErr();
		return null;
	}
	public function p_RotateLeft2(t_node:c_Node9):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<251>";
		var t_child:c_Node9=dbg_object(t_node).m_right;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<252>";
		dbg_object(t_node).m_right=dbg_object(t_child).m_left;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<253>";
		if((dbg_object(t_child).m_left)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<254>";
			dbg_object(dbg_object(t_child).m_left).m_parent=t_node;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<256>";
		dbg_object(t_child).m_parent=dbg_object(t_node).m_parent;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<257>";
		if((dbg_object(t_node).m_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<258>";
			if(t_node==dbg_object(dbg_object(t_node).m_parent).m_left){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<259>";
				dbg_object(dbg_object(t_node).m_parent).m_left=t_child;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<261>";
				dbg_object(dbg_object(t_node).m_parent).m_right=t_child;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<264>";
			m_root=t_child;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<266>";
		dbg_object(t_child).m_left=t_node;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<267>";
		dbg_object(t_node).m_parent=t_child;
		popErr();
		return 0;
	}
	public function p_RotateRight2(t_node:c_Node9):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<271>";
		var t_child:c_Node9=dbg_object(t_node).m_left;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<272>";
		dbg_object(t_node).m_left=dbg_object(t_child).m_right;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<273>";
		if((dbg_object(t_child).m_right)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<274>";
			dbg_object(dbg_object(t_child).m_right).m_parent=t_node;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<276>";
		dbg_object(t_child).m_parent=dbg_object(t_node).m_parent;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<277>";
		if((dbg_object(t_node).m_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<278>";
			if(t_node==dbg_object(dbg_object(t_node).m_parent).m_right){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<279>";
				dbg_object(dbg_object(t_node).m_parent).m_right=t_child;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<281>";
				dbg_object(dbg_object(t_node).m_parent).m_left=t_child;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<284>";
			m_root=t_child;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<286>";
		dbg_object(t_child).m_right=t_node;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<287>";
		dbg_object(t_node).m_parent=t_child;
		popErr();
		return 0;
	}
	public function p_InsertFixup2(t_node:c_Node9):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<212>";
		while(((dbg_object(t_node).m_parent)!=null) && dbg_object(dbg_object(t_node).m_parent).m_color==-1 && ((dbg_object(dbg_object(t_node).m_parent).m_parent)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<213>";
			if(dbg_object(t_node).m_parent==dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_left){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<214>";
				var t_uncle:c_Node9=dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_right;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<215>";
				if(((t_uncle)!=null) && dbg_object(t_uncle).m_color==-1){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<216>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<217>";
					dbg_object(t_uncle).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<218>";
					dbg_object(dbg_object(t_uncle).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<219>";
					t_node=dbg_object(t_uncle).m_parent;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<221>";
					if(t_node==dbg_object(dbg_object(t_node).m_parent).m_right){
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<222>";
						t_node=dbg_object(t_node).m_parent;
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<223>";
						this.p_RotateLeft2(t_node);
					}
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<225>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<226>";
					dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<227>";
					this.p_RotateRight2(dbg_object(dbg_object(t_node).m_parent).m_parent);
				}
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<230>";
				var t_uncle2:c_Node9=dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_left;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<231>";
				if(((t_uncle2)!=null) && dbg_object(t_uncle2).m_color==-1){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<232>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<233>";
					dbg_object(t_uncle2).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<234>";
					dbg_object(dbg_object(t_uncle2).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<235>";
					t_node=dbg_object(t_uncle2).m_parent;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<237>";
					if(t_node==dbg_object(dbg_object(t_node).m_parent).m_left){
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<238>";
						t_node=dbg_object(t_node).m_parent;
						_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<239>";
						this.p_RotateRight2(t_node);
					}
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<241>";
					dbg_object(dbg_object(t_node).m_parent).m_color=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<242>";
					dbg_object(dbg_object(dbg_object(t_node).m_parent).m_parent).m_color=-1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<243>";
					this.p_RotateLeft2(dbg_object(dbg_object(t_node).m_parent).m_parent);
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<247>";
		dbg_object(m_root).m_color=1;
		popErr();
		return 0;
	}
	public function p_Set2(t_key:c_Vector,t_value:c_NormHelperClass):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<29>";
		var t_node:c_Node9=m_root;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<30>";
		var t_parent:c_Node9=null;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<30>";
		var t_cmp:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<32>";
		while((t_node)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<33>";
			t_parent=t_node;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<34>";
			t_cmp=this.p_Compare3(t_key,dbg_object(t_node).m_key);
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<35>";
			if(t_cmp>0){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<36>";
				t_node=dbg_object(t_node).m_right;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<37>";
				if(t_cmp<0){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<38>";
					t_node=dbg_object(t_node).m_left;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<40>";
					dbg_object(t_node).m_value=t_value;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<41>";
					popErr();
					return false;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<45>";
		t_node=(new c_Node9).m_Node_new(t_key,t_value,-1,t_parent);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<47>";
		if((t_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<48>";
			if(t_cmp>0){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<49>";
				dbg_object(t_parent).m_right=t_node;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<51>";
				dbg_object(t_parent).m_left=t_node;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<53>";
			this.p_InsertFixup2(t_node);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<55>";
			m_root=t_node;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<57>";
		popErr();
		return true;
	}
}
class c_NormMap extends c_Map2{
	public function m_NormMap_new():c_NormMap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<967>";
		super.m_Map_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<967>";
		popErr();
		return this;
	}
	public override function p_Compare3(t_lhs:c_Vector,t_rhs:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<969>";
		if(dbg_object(t_lhs).m_x<dbg_object(t_rhs).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<969>";
			popErr();
			return -1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<970>";
		if(dbg_object(t_lhs).m_x>dbg_object(t_rhs).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<970>";
			popErr();
			return 1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<971>";
		if(dbg_object(t_lhs).m_y<dbg_object(t_rhs).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<971>";
			popErr();
			return -1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<972>";
		if(dbg_object(t_lhs).m_y>dbg_object(t_rhs).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<972>";
			popErr();
			return 1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<973>";
		if(dbg_object(t_lhs).m_z<dbg_object(t_rhs).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<973>";
			popErr();
			return -1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsurface.monkey<974>";
		var t_:int=((dbg_object(t_lhs).m_z>dbg_object(t_rhs).m_z)?1:0);
		popErr();
		return t_;
	}
}
class c_Node9 extends Object{
	internal var m_key:c_Vector=null;
	internal var m_right:c_Node9=null;
	internal var m_left:c_Node9=null;
	internal var m_value:c_NormHelperClass=null;
	internal var m_color:int=0;
	internal var m_parent:c_Node9=null;
	public function m_Node_new(t_key:c_Vector,t_value:c_NormHelperClass,t_color:int,t_parent:c_Node9):c_Node9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<364>";
		dbg_object(this).m_key=t_key;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<365>";
		dbg_object(this).m_value=t_value;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<366>";
		dbg_object(this).m_color=t_color;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<367>";
		dbg_object(this).m_parent=t_parent;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/map.monkey<361>";
		popErr();
		return this;
	}
}
interface c_IRenderUpdate{
	function p_Update2(t_cam:c_TCamera):int;
}
class c_TSprite extends c_TMesh implements c_IRenderUpdate{
	public function m_TSprite_new():c_TSprite{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<23>";
		super.m_TMesh_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<25>";
		m_is_sprite=true;
		popErr();
		return this;
	}
	internal var m_pixel_scale:Array=new_number_array(2);
	internal var m_mat_sp:c_Matrix=(new c_Matrix).m_Matrix_new();
	public static function m_CreateSprite(t_parent_ent:c_TEntity):c_TSprite{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<62>";
		var t_sprite:c_TSprite=(new c_TSprite).m_TSprite_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<63>";
		dbg_object(t_sprite).m_classname="Sprite";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<65>";
		t_sprite.p_AddParent(t_parent_ent);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<66>";
		dbg_object(t_sprite).m_entity_link=c_TEntity.m_entity_list.p_EntityListAdd(t_sprite);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<69>";
		if(dbg_object(t_sprite).m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<70>";
			dbg_object(t_sprite).m_mat.p_Overwrite(dbg_object(dbg_object(t_sprite).m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<71>";
			t_sprite.p_UpdateMat(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<73>";
			t_sprite.p_UpdateMat(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<76>";
		var t_surf:c_TSurface=t_sprite.p_CreateSurface(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<79>";
		dbg_object(t_surf).m_vert_data=c_VertexDataBuffer.m_Create(4);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<80>";
		dbg_object(t_surf).m_vert_array_size=5;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<81>";
		dbg_object(t_surf).m_tris=c_ShortBuffer.m_Create(12);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<82>";
		dbg_object(t_surf).m_tri_array_size=5;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<91>";
		t_surf.p_AddVertex2([-1.0,-1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,-1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],-1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<92>";
		t_surf.p_AddTriangle2([0,1,2,0,2,3],-1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<98>";
		t_sprite.p_EntityFX(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<100>";
		popErr();
		return t_sprite;
	}
	public function p_AutoResizeTexture(t_tex:c_TTexture):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<130>";
		var t_x:Number=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<130>";
		var t_y:Number=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<131>";
		if(dbg_object(t_tex).m_orig_height>dbg_object(t_tex).m_orig_width){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<131>";
			t_y=(dbg_object(t_tex).m_orig_height)/(dbg_object(t_tex).m_orig_width);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<132>";
		if(dbg_object(t_tex).m_orig_height<dbg_object(t_tex).m_orig_width){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<132>";
			t_x=(dbg_object(t_tex).m_orig_width)/(dbg_object(t_tex).m_orig_height);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<133>";
		this.p_GetSurface(1).p_VertexCoords(0,-t_x,-t_y,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<134>";
		this.p_GetSurface(1).p_VertexCoords(1,-t_x,t_y,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<135>";
		this.p_GetSurface(1).p_VertexCoords(2,t_x,t_y,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<136>";
		this.p_GetSurface(1).p_VertexCoords(3,t_x,-t_y,0.0);
		popErr();
	}
	public static function m_CreateSprite2(t_tex:c_TTexture,t_parent_ent:c_TEntity):c_TSprite{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<107>";
		var t_sprite:c_TSprite=m_CreateSprite(t_parent_ent);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<109>";
		t_sprite.p_EntityTexture(t_tex,0,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<112>";
		if((dbg_object(t_tex).m_flags&2)==0 && (dbg_object(t_tex).m_flags&4)==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<113>";
			t_sprite.p_EntityBlend(3);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<117>";
		if(dbg_object(t_tex).m_orig_width!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<119>";
			t_sprite.p_AutoResizeTexture(t_tex);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<123>";
		popErr();
		return t_sprite;
	}
	internal var m_scale_x:Number=1.0;
	internal var m_scale_y:Number=1.0;
	public function p_ScaleSprite(t_s_x:Number,t_s_y:Number):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<156>";
		m_scale_x=t_s_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<157>";
		m_scale_y=t_s_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<160>";
		if((m_parent)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<161>";
			m_gsx=t_s_x*dbg_object(m_parent).m_gsx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<161>";
			m_gsy=t_s_y*dbg_object(m_parent).m_gsy;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<161>";
			m_gsz=m_gsx;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<163>";
			m_gsx=t_s_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<163>";
			m_gsy=t_s_y;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<163>";
			m_gsz=m_gsx;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<166>";
		var t_:c_TEntity=(this);
		popErr();
		return t_;
	}
	public override function p_ScaleEntity(t_x:Number,t_y:Number,t_z:Number,t_glob:int):c_TEntity{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<178>";
		this.p_ScaleSprite(t_x,t_y);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<179>";
		var t_:c_TEntity=(this);
		popErr();
		return t_;
	}
	internal var m_view_mode:int=1;
	internal static var m_temp_mat:c_Matrix;
	internal var m_angle:Number=.0;
	internal var m_handle_x:Number=.0;
	internal var m_handle_y:Number=.0;
	public function p_Update2(t_cam:c_TCamera):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<199>";
		if(m_view_mode!=2){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<201>";
			var t_x:Number=dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<202>";
			var t_y:Number=dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<203>";
			var t_z:Number=dbg_array(dbg_array(dbg_object(m_mat).m_grid,3)[dbg_index],2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<205>";
			m_temp_mat.p_Overwrite(dbg_object(t_cam).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<206>";
			dbg_array(dbg_array(dbg_object(m_temp_mat).m_grid,3)[dbg_index],0)[dbg_index]=t_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<207>";
			dbg_array(dbg_array(dbg_object(m_temp_mat).m_grid,3)[dbg_index],1)[dbg_index]=t_y;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<208>";
			dbg_array(dbg_array(dbg_object(m_temp_mat).m_grid,3)[dbg_index],2)[dbg_index]=t_z;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<209>";
			m_mat_sp.p_Overwrite(m_temp_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<211>";
			if(m_angle!=0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<212>";
				m_mat_sp.p_RotateRoll(m_angle);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<215>";
			if(m_scale_x!=1.0 || m_scale_y!=1.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<216>";
				m_mat_sp.p_Scale(m_scale_x,m_scale_y,1.0);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<219>";
			if(m_handle_x!=0.0 || m_handle_y!=0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<220>";
				m_mat_sp.p_Translate(-m_handle_x,-m_handle_y,0.0);
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<225>";
			m_mat_sp.p_Overwrite(m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<227>";
			if(m_scale_x!=1.0 || m_scale_y!=1.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tsprite.monkey<228>";
				m_mat_sp.p_Scale(m_scale_x,m_scale_y,1.0);
			}
		}
		popErr();
		return 0;
	}
}
class c_TText extends c_TSprite{
	public function m_TText_new():c_TText{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<9>";
		super.m_TSprite_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<9>";
		popErr();
		return this;
	}
	internal var m_text:String="";
	internal var m_length:int=0;
	internal var m_cam:c_TCamera=null;
	internal var m_char_pixels:Number=.0;
	internal var m_font_file:String="";
	internal var m_orig_width:Number=.0;
	internal var m_orig_height:Number=.0;
	internal static var m_mask_color:int;
	internal var m_surf:c_TSurface=null;
	internal var m_char_rows:int=0;
	internal var m_pixel_ratio:Number=.0;
	internal var m_char_uvwidth:Number=.0;
	internal var m_padding:int=0;
	internal var m_mode:Boolean=true;
	internal var m_old_text:String="";
	public function p_AddChar(t_char:int,t_num:int,t_x:Number,t_y:Number,t_offset:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<158>";
		var t_uv:Number=((t_char)-32.0)*m_char_uvwidth+((t_char)-32.0)*(m_padding);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<159>";
		var t_uv2:Number=0.9999;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<161>";
		if(t_char==32){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<161>";
			t_uv=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<161>";
			t_uv2=0.0001;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<162>";
		if(t_uv<0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<162>";
			t_uv=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<162>";
			t_uv2=0.0001;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<166>";
		var t_kern:Number=0.3*t_x+t_offset;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<168>";
		m_surf.p_AddVertex(0.0+t_x-t_kern,0.0+t_y,0.0,t_uv,t_uv2,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<169>";
		m_surf.p_AddVertex(0.0+t_x-t_kern,1.0+t_y,0.0,t_uv,0.0001,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<170>";
		m_surf.p_AddVertex(1.0+t_x-t_kern,1.0+t_y,0.0,t_uv+m_char_uvwidth,0.0001,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<171>";
		m_surf.p_AddVertex(1.0+t_x-t_kern,0.0+t_y,0.0,t_uv+m_char_uvwidth,t_uv2,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<172>";
		var t_v:int=t_num*4;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<173>";
		m_surf.p_AddTriangle(0+t_v,1+t_v,2+t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<174>";
		m_surf.p_AddTriangle(0+t_v,2+t_v,3+t_v);
		popErr();
		return 0;
	}
	public function p_AdjustChar(t_char:int,t_num:int,t_x:Number,t_y:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<180>";
		var t_uv:Number=((t_char)-32.0)*m_char_uvwidth+((t_char)-32.0)*(m_padding);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<181>";
		var t_uv2:Number=0.9999;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<183>";
		if(t_char==32){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<183>";
			t_uv=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<183>";
			t_uv2=0.0001;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<184>";
		if(t_uv<0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<184>";
			t_uv=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<184>";
			t_uv2=0.0001;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<187>";
		var t_kern:Number=0.3*t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<189>";
		var t_v:int=t_num*4;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<190>";
		m_surf.p_VertexTexCoords(t_v+0,t_uv,t_uv2,0.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<191>";
		m_surf.p_VertexTexCoords(t_v+1,t_uv,0.0001,0.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<192>";
		m_surf.p_VertexTexCoords(t_v+2,t_uv+m_char_uvwidth,0.0001,0.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<193>";
		m_surf.p_VertexTexCoords(t_v+3,t_uv+m_char_uvwidth,t_uv2,0.0,0);
		popErr();
		return 0;
	}
	public function p_SetText(t_str:String,t_x:Number,t_y:Number,t_z:Number,t_align:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<211>";
		var t_resurf:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<213>";
		if(m_mode==false){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<215>";
			this.p_PositionEntity(t_x,t_y,t_z,0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<231>";
		if(t_str==m_old_text || t_str==""){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<231>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<233>";
		if(t_str.length!=m_old_text.length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<234>";
			if((m_surf)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<235>";
				m_surf.p_ClearSurface(true,true,false);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<237>";
				m_surf=this.p_CreateSurface(null);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<240>";
			t_resurf=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<245>";
		m_old_text=t_str;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<247>";
		var t_nl:int=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<247>";
		var t_xx:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<247>";
		var t_total:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<250>";
		var t_offset:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<251>";
		if(t_align==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<251>";
			t_offset=(t_str.length)*0.15;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<253>";
		for(var t_i:int=0;t_i<=t_str.length-1;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<255>";
			if(dbg_charCodeAt(t_str,t_i)==13 || dbg_charCodeAt(t_str,t_i)==10){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<256>";
				t_nl=t_nl-1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<257>";
				t_xx=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<258>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<261>";
			if((t_resurf)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<261>";
				this.p_AddChar(dbg_charCodeAt(t_str,t_i),t_total,(t_xx),(t_nl),t_offset);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<261>";
				this.p_AdjustChar(dbg_charCodeAt(t_str,t_i),t_total,(t_xx),(t_nl));
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<262>";
			t_xx+=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<263>";
			t_total+=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<266>";
		if((t_resurf)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<266>";
			m_surf.p_CropSurfaceBuffers();
		}
		popErr();
		return 0;
	}
	public static function m_CreateText(t_camx:c_TCamera,t_str:String,t_font:String,t_num_chars:int,t_c_pixels:int,t_pad:Number,t_mode:Boolean):c_TText{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<57>";
		var t_tt:c_TText=(new c_TText).m_TText_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<59>";
		dbg_object(t_tt).m_entity_link=c_TEntity.m_entity_list.p_EntityListAdd(t_tt);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<61>";
		dbg_object(t_tt).m_text=t_str;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<62>";
		dbg_object(t_tt).m_length=t_str.length;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<63>";
		dbg_object(t_tt).m_cam=t_camx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<64>";
		dbg_object(t_tt).m_classname="TextSprite";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<65>";
		dbg_object(t_tt).m_is_sprite=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<67>";
		dbg_object(t_tt).m_char_pixels=(t_c_pixels);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<69>";
		if(t_font!=""){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<70>";
			dbg_object(t_tt).m_font_file=t_font;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<73>";
			dbg_object(t_tt).m_font_file="mojo_font.png";
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<77>";
		c_TTexture.m_useGlobalResizeSmooth=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<80>";
		var t_pixmap:c_TPixmap=c_TPixmap.m_LoadPixmap(dbg_object(t_tt).m_font_file).p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<81>";
		dbg_object(t_tt).m_orig_width=(dbg_object(t_pixmap).m_width);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<81>";
		dbg_object(t_tt).m_orig_height=(dbg_object(t_pixmap).m_height);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<83>";
		if(dbg_object(t_pixmap).m_height==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<83>";
			print("Font file not found.");
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<83>";
			popErr();
			return t_tt;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<86>";
		t_pixmap.p_MaskPixmap(m_mask_color&255,(m_mask_color&65280)>>8,(m_mask_color&16711680)>>16);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<87>";
		var t_tex:c_TTexture=c_TTexture.m_LoadTexture2(t_pixmap,3,null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<90>";
		c_TTexture.m_useGlobalResizeSmooth=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<92>";
		dbg_object(t_tex).m_is_font=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<93>";
		dbg_object(t_tex).m_flags=50;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<94>";
		t_tex.p_TextureBlend(2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<96>";
		t_tt.p_EntityShininess(0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<98>";
		dbg_object(t_tt).m_surf=t_tt.p_CreateSurface(null);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<99>";
		t_tt.p_EntityTexture(t_tex,0,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<100>";
		dbg_object(t_tt).m_char_rows=((Math.ceil(((t_c_pixels*t_num_chars)+(t_num_chars)*(t_pad*2.0))/dbg_object(t_tt).m_orig_width))|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<102>";
		dbg_object(t_tt).m_pixel_ratio=(dbg_object(t_tex).m_width)/dbg_object(t_tt).m_orig_width;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<104>";
		var t_temp_chars_per_row:int=((Math.floor((t_num_chars/dbg_object(t_tt).m_char_rows)|0))|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<105>";
		dbg_object(t_tt).m_char_uvwidth=dbg_object(t_tt).m_char_pixels*dbg_object(t_tt).m_pixel_ratio/(dbg_object(t_tex).m_width);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<106>";
		dbg_object(t_tt).m_padding=((dbg_object(t_tt).m_pixel_ratio*t_pad)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<112>";
		if(dbg_object(t_tt).m_parent!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<113>";
			dbg_object(t_tt).m_mat.p_Overwrite(dbg_object(dbg_object(t_tt).m_parent).m_mat);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<114>";
			t_tt.p_UpdateMat(false);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<116>";
			t_tt.p_UpdateMat(true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<119>";
		t_tt.p_EntityFX(33);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<120>";
		t_tt.p_SetText(t_str,0.0,0.0,0.0,0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<122>";
		popErr();
		return t_tt;
	}
	public static function m_CreateText2D(t_camx:c_TCamera,t_str:String,t_font:String,t_num_chars:int,t_c_pixels:int,t_pad:int):c_TText{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<49>";
		var t_tt:c_TText=m_CreateText(t_camx,t_str,t_font,t_num_chars,t_c_pixels,(t_pad),true);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<50>";
		t_tt.p_HideEntity();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttext.monkey<51>";
		popErr();
		return t_tt;
	}
}
interface c_IPixmapManager{
	function p_LoadPixmap(t_f:String):c_TPixmap;
	function p_CreatePixmap(t_w:int,t_h:int,t_format:int):c_TPixmap;
}
class c_TTextureFilter extends Object{
	internal static var m_filter_list:c_List8;
	internal var m_text:String="";
	internal var m_flags:int=0;
	public function m_TTextureFilter_new():c_TTextureFilter{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<790>";
		popErr();
		return this;
	}
}
class c_List8 extends Object{
	public function m_List_new():c_List8{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node10=((new c_HeadNode8).m_HeadNode_new());
	public function p_AddLast8(t_data:c_TTextureFilter):c_Node10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node10=(new c_Node10).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TTextureFilter=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast8(t_t);
		}
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_Enumerator4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator4=(new c_Enumerator4).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_Node10 extends Object{
	internal var m__succ:c_Node10=null;
	internal var m__pred:c_Node10=null;
	internal var m__data:c_TTextureFilter=null;
	public function m_Node_new(t_succ:c_Node10,t_pred:c_Node10,t_data:c_TTextureFilter):c_Node10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode8 extends c_Node10{
	public function m_HeadNode_new():c_HeadNode8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_Enumerator4 extends Object{
	internal var m__list:c_List8=null;
	internal var m__curr:c_Node10=null;
	public function m_Enumerator_new(t_list:c_List8):c_Enumerator4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TTextureFilter{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TTextureFilter=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_List9 extends Object{
	public function m_List_new():c_List9{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node11=((new c_HeadNode9).m_HeadNode_new());
	public function p_AddLast9(t_data:c_TTexture):c_Node11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node11=(new c_Node11).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TTexture=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast9(t_t);
		}
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_Enumerator5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator5=(new c_Enumerator5).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_Node11 extends Object{
	internal var m__succ:c_Node11=null;
	internal var m__pred:c_Node11=null;
	internal var m__data:c_TTexture=null;
	public function m_Node_new(t_succ:c_Node11,t_pred:c_Node11,t_data:c_TTexture):c_Node11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
	public function p_Remove():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<274>";
		if(dbg_object(m__succ).m__pred!=this){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<274>";
			error("Illegal operation on removed node");
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<276>";
		dbg_object(m__succ).m__pred=m__pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<277>";
		dbg_object(m__pred).m__succ=m__succ;
		popErr();
		return 0;
	}
}
class c_HeadNode9 extends c_Node11{
	public function m_HeadNode_new():c_HeadNode9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_Enumerator5 extends Object{
	internal var m__list:c_List9=null;
	internal var m__curr:c_Node11=null;
	public function m_Enumerator_new(t_list:c_List9):c_Enumerator5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator5{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TTexture=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_Stack3 extends Object{
	public function m_Stack_new():c_Stack3{
		pushErr();
		popErr();
		return this;
	}
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_Stack_new2(t_data:Array):c_Stack3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<13>";
		dbg_object(this).m_data=t_data.slice(0);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<14>";
		dbg_object(this).m_length=t_data.length;
		popErr();
		return this;
	}
	public function p_Push7(t_value:c_TTexture):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<67>";
		if(m_length==m_data.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<68>";
			m_data=resize_object_array(m_data,m_length*2+10);
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<70>";
		dbg_array(m_data,m_length)[dbg_index]=t_value;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<71>";
		m_length+=1;
		popErr();
	}
	public function p_Push8(t_values:Array,t_offset:int,t_count:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<79>";
		for(var t_i:int=0;t_i<t_count;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<80>";
			this.p_Push7(dbg_array(t_values,t_offset+t_i)[dbg_index]);
		}
		popErr();
	}
	public function p_Push9(t_values:Array,t_offset:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<75>";
		this.p_Push8(t_values,t_offset,t_values.length-t_offset);
		popErr();
	}
	internal static var m_NIL:c_TTexture;
	public function p_Length2(t_newlength:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<41>";
		if(t_newlength<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<42>";
			for(var t_i:int=t_newlength;t_i<m_length;t_i=t_i+1){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<43>";
				dbg_array(m_data,t_i)[dbg_index]=m_NIL;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<45>";
			if(t_newlength>m_data.length){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<46>";
				m_data=resize_object_array(m_data,bb_math_Max(m_length*2+10,t_newlength));
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<48>";
		m_length=t_newlength;
		popErr();
	}
	public function p_Length():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<52>";
		popErr();
		return m_length;
	}
	public function p_ObjectEnumerator():c_Enumerator10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<184>";
		var t_:c_Enumerator10=(new c_Enumerator10).m_Enumerator_new(this);
		popErr();
		return t_;
	}
	public function p_Clear():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<34>";
		for(var t_i:int=0;t_i<m_length;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<35>";
			dbg_array(m_data,t_i)[dbg_index]=m_NIL;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<37>";
		m_length=0;
		popErr();
	}
}
class c_TextureStack extends c_Stack3{
	public function m_TextureStack_new():c_TextureStack{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<37>";
		super.m_Stack_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/ttexture.monkey<37>";
		popErr();
		return this;
	}
}
internal function bb_input_KeyDown(t_key:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/input.monkey<40>";
	var t_:int=((bb_input_device.p_KeyDown(t_key))?1:0);
	popErr();
	return t_;
}
internal function bb_input_TouchDown(t_index:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/input.monkey<84>";
	var t_:int=((bb_input_device.p_KeyDown(384+t_index))?1:0);
	popErr();
	return t_;
}
internal function bb_input_TouchX(t_index:int):Number{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/input.monkey<76>";
	var t_:Number=bb_input_device.p_TouchX(t_index);
	popErr();
	return t_;
}
internal function bb_input_TouchY(t_index:int):Number{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/mojo/input.monkey<80>";
	var t_:Number=bb_input_device.p_TouchY(t_index);
	popErr();
	return t_;
}
class c_CollisionInfo extends Object{
	internal static var m_t_mat:c_Matrix;
	internal var m_tform:c_TransformMat=(new c_TransformMat).m_TransformMat_new();
	public function m_CollisionInfo_new():c_CollisionInfo{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<451>";
		m_t_mat=(new c_Matrix).m_Matrix_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<452>";
		m_tform=(new c_TransformMat).m_TransformMat_new();
		popErr();
		return this;
	}
	internal static var m_col_info:c_CollisionInfo;
	internal var m_src_radius:Number=.0;
	internal var m_dst_radius:Number=.0;
	internal var m_planes:Array=[(new c_Plane).m_Plane_new4(),(new c_Plane).m_Plane_new4(),(new c_Plane).m_Plane_new4(),(new c_Plane).m_Plane_new4()];
	internal var m_col_points:Array=[(new c_Vector).m_Vector_new(0.0,0.0,0.0),(new c_Vector).m_Vector_new(0.0,0.0,0.0),(new c_Vector).m_Vector_new(0.0,0.0,0.0),(new c_Vector).m_Vector_new(0.0,0.0,0.0)];
	internal var m_src_divSphere:c_DivSphereInfo=(new c_DivSphereInfo).m_DivSphereInfo_new();
	internal var m_dst_divSphere:c_DivSphereInfo=(new c_DivSphereInfo).m_DivSphereInfo_new();
	internal var m_dst_entity:c_TEntity=null;
	public function p_Clear():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<457>";
		m_src_radius=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<458>";
		m_dst_radius=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<460>";
		dbg_array(m_planes,0)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<461>";
		dbg_array(m_planes,1)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<462>";
		dbg_array(m_planes,2)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<463>";
		dbg_array(m_planes,3)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<464>";
		dbg_array(m_col_points,0)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<465>";
		dbg_array(m_col_points,1)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<466>";
		dbg_array(m_col_points,2)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<467>";
		dbg_array(m_col_points,3)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<469>";
		m_src_divSphere.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<470>";
		m_dst_divSphere.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<473>";
		m_dst_entity=null;
		popErr();
	}
	internal var m_hitDivOffset:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_hitDivRadius:Number=0.0;
	public function p_UpdateSourceSphere(t_ent:c_TEntity):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<602>";
		if(dbg_object(dbg_object(t_ent).m_collision).m_radius_x==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<607>";
			var t_sc:Number=bb_math_Max2(bb_math_Max2(bb_math_Abs2(dbg_object(t_ent).m_gsx),bb_math_Abs2(dbg_object(t_ent).m_gsy)),bb_math_Abs2(dbg_object(t_ent).m_gsz));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<608>";
			m_src_radius=t_ent.p_EntityRadius(0.0,0.0)*t_sc;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<614>";
		dbg_object(m_src_divSphere).m_offset.p_Overwrite2(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<615>";
		m_hitDivOffset.p_Overwrite2(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<616>";
		m_hitDivRadius=0.0;
		popErr();
		return 0;
	}
	internal var m_vec_a:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_vec_b:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_vec_c:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_hits:int=0;
	internal var m_n_hit:int=0;
	internal var m_ax:Number=.0;
	internal var m_ay:Number=.0;
	internal var m_az:Number=.0;
	internal var m_bx:Number=.0;
	internal var m_by:Number=.0;
	internal var m_bz:Number=.0;
	public function p_ClearHitPlanes():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<527>";
		dbg_array(m_planes,0)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<528>";
		dbg_array(m_planes,1)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<529>";
		dbg_array(m_planes,2)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<530>";
		dbg_array(m_planes,3)[dbg_index].p_Update9(0.0,0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<531>";
		dbg_array(m_col_points,0)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<532>";
		dbg_array(m_col_points,1)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<533>";
		dbg_array(m_col_points,2)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<534>";
		dbg_array(m_col_points,3)[dbg_index].p_Update(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<538>";
		m_hits=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<538>";
		m_n_hit=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<540>";
		m_ax=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<541>";
		m_ay=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<542>";
		m_az=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<543>";
		m_bx=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<544>";
		m_by=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<545>";
		m_bz=1.0;
		popErr();
	}
	internal var m_dv:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_sv:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_panic:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_radii:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_coll_line:c_Line=(new c_Line).m_Line_new();
	internal var m_ray_length:Number=.0;
	internal var m_ray_dir:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_ray_center:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_y_scale:Number=.0;
	internal var m_inv_y_scale:Number=.0;
	internal var m_y_tform:c_TransformMat=(new c_TransformMat).m_TransformMat_new();
	public function p_UpdateRay(t_sv2:c_Vector,t_dv2:c_Vector,t_radii2:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<479>";
		m_t_mat.p_LoadIdentity();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<480>";
		dbg_object(m_tform).m_m.p_LoadIdentity();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<482>";
		m_dv.p_Overwrite3(t_dv2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<483>";
		m_sv.p_Overwrite3(t_sv2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<484>";
		m_panic.p_Overwrite3(t_sv2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<485>";
		m_radii.p_Overwrite3(t_radii2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<486>";
		m_src_radius=dbg_object(m_radii).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<491>";
		m_coll_line.p_Update3(dbg_object(m_sv).m_x,dbg_object(m_sv).m_y,dbg_object(m_sv).m_z,dbg_object(m_dv).m_x-dbg_object(m_sv).m_x,dbg_object(m_dv).m_y-dbg_object(m_sv).m_y,dbg_object(m_dv).m_z-dbg_object(m_sv).m_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<495>";
		m_ray_length=dbg_object(m_coll_line).m_d.p_Length();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<496>";
		if(m_ray_length>0.00001){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<497>";
			m_ray_dir=m_coll_line.p_Multiply5(1.0/m_ray_length);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<499>";
			m_ray_dir=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<501>";
		m_ray_center.p_Update(dbg_object(dbg_object(m_coll_line).m_o).m_x+dbg_object(dbg_object(m_coll_line).m_d).m_x*0.5,dbg_object(dbg_object(m_coll_line).m_o).m_y+dbg_object(dbg_object(m_coll_line).m_d).m_y*0.5,dbg_object(dbg_object(m_coll_line).m_o).m_z+dbg_object(dbg_object(m_coll_line).m_d).m_z*0.5);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<510>";
		m_y_scale=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<511>";
		m_inv_y_scale=1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<512>";
		dbg_array(dbg_array(dbg_object(dbg_object(m_y_tform).m_m).m_grid,1)[dbg_index],1)[dbg_index]=1.0;
		popErr();
		return 0;
	}
	internal var m_col_passes:int=0;
	internal static var m_starttime:Number;
	internal var m_dst_pos:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	public function p_UpdateDestShape(t_ent:c_TEntity):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<550>";
		if(!dbg_object(dbg_object(t_ent).m_collision).m_updated_shape){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<553>";
			var t_sc:Number=bb_math_Max2(bb_math_Max2(bb_math_Abs2(dbg_object(t_ent).m_gsx),bb_math_Abs2(dbg_object(t_ent).m_gsy)),bb_math_Abs2(dbg_object(t_ent).m_gsz));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<554>";
			if(dbg_object(dbg_object(t_ent).m_collision).m_radius_x!=0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<556>";
				m_dst_radius=dbg_object(dbg_object(t_ent).m_collision).m_radius_x*t_sc;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<561>";
				m_dst_radius=t_ent.p_EntityRadius(0.0,0.0)*t_sc;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<566>";
			if(dbg_object(dbg_object(t_ent).m_collision).m_box_w==0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<568>";
				t_ent.p_EntityBox(0.0,0.0,0.0,0.0,0.0,0.0);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<572>";
			m_ax=dbg_object(dbg_object(t_ent).m_collision).m_box_x*t_sc;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<573>";
			m_ay=dbg_object(dbg_object(t_ent).m_collision).m_box_y*t_sc;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<574>";
			m_az=dbg_object(dbg_object(t_ent).m_collision).m_box_z*t_sc;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<575>";
			m_bx=dbg_object(dbg_object(t_ent).m_collision).m_box_x+dbg_object(dbg_object(t_ent).m_collision).m_box_w*t_sc;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<576>";
			m_by=dbg_object(dbg_object(t_ent).m_collision).m_box_y+dbg_object(dbg_object(t_ent).m_collision).m_box_h*t_sc;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<577>";
			m_bz=dbg_object(dbg_object(t_ent).m_collision).m_box_z+dbg_object(dbg_object(t_ent).m_collision).m_box_d*t_sc;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<579>";
			dbg_object(dbg_object(t_ent).m_collision).m_updated_shape=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<580>";
			dbg_object(dbg_object(t_ent).m_collision).m_sa=[m_ax,m_ay,m_az,m_bx,m_by,m_bz];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<581>";
			dbg_object(dbg_object(t_ent).m_collision).m_old_dst_radius=m_dst_radius;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<585>";
			m_dst_radius=dbg_object(dbg_object(t_ent).m_collision).m_old_dst_radius;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<586>";
			m_ax=dbg_array(dbg_object(dbg_object(t_ent).m_collision).m_sa,0)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<587>";
			m_ay=dbg_array(dbg_object(dbg_object(t_ent).m_collision).m_sa,1)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<588>";
			m_az=dbg_array(dbg_object(dbg_object(t_ent).m_collision).m_sa,2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<589>";
			m_bx=dbg_array(dbg_object(dbg_object(t_ent).m_collision).m_sa,3)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<590>";
			m_by=dbg_array(dbg_object(dbg_object(t_ent).m_collision).m_sa,4)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<591>";
			m_bz=dbg_array(dbg_object(dbg_object(t_ent).m_collision).m_sa,5)[dbg_index];
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<595>";
		dbg_object(m_dst_divSphere).m_offset.p_Overwrite2(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<596>";
		m_dst_pos.p_Update(dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index],-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index]);
		popErr();
		return 0;
	}
	internal var m_coll_method:int=0;
	internal static var m_nullVec:c_Vector;
	internal var m_inv_scale:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_renew2:c_Matrix=(new c_Matrix).m_Matrix_new();
	internal var m_tf_scale:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_tf_radius:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_tf_line:c_Line=(new c_Line).m_Line_new();
	internal var m_tf_offset:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	public function p_CreateCollLine(t_li:c_Line,t_ent:c_TEntity,t_mat:c_Matrix,t_offset2:c_Vector):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<900>";
		if(m_coll_method==2 || m_coll_method==3 || m_coll_method==5){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<901>";
			m_tf_offset.p_Overwrite2(-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index],-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index]);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<905>";
			t_li.p_Update4(m_coll_line);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<908>";
			c_Vec3.m_Add(dbg_object(t_li).m_o,m_tf_offset,dbg_object(t_li).m_o);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<908>";
			c_Vec3.m_Add(dbg_object(t_li).m_o,dbg_object(m_src_divSphere).m_offset,dbg_object(t_li).m_o);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<909>";
			c_Vec3.m_Multiply3(dbg_object(t_li).m_o,dbg_object(m_tform).m_m,dbg_object(t_li).m_o);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<911>";
			c_Vec3.m_Multiply3(dbg_object(t_li).m_d,dbg_object(m_tform).m_m,dbg_object(t_li).m_d);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<916>";
			m_tf_offset.p_Overwrite2(dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index],-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index]);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<921>";
			c_Vec3.m_Add(dbg_object(m_src_divSphere).m_offset,dbg_object(m_coll_line).m_o,dbg_object(t_li).m_o);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<922>";
			dbg_object(t_li).m_d.p_Overwrite3(dbg_object(m_coll_line).m_d);
		}
		popErr();
	}
	internal var m_tf_box:c_Box=(new c_Box).m_Box_new();
	public function p_CollisionBoxSetup(t_ent:c_TEntity,t_radius:Number,t_coll_obj:c_CollisionObject):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<968>";
		m_tf_box.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<969>";
		dbg_object(m_tf_box).m_a.p_Overwrite2(dbg_object(dbg_object(t_ent).m_collision).m_box_x,dbg_object(dbg_object(t_ent).m_collision).m_box_y,dbg_object(dbg_object(t_ent).m_collision).m_box_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<970>";
		m_tf_box.p_Update10((new c_Vector).m_Vector_new(dbg_object(dbg_object(t_ent).m_collision).m_box_x+dbg_object(dbg_object(t_ent).m_collision).m_box_w,dbg_object(dbg_object(t_ent).m_collision).m_box_y+dbg_object(dbg_object(t_ent).m_collision).m_box_h,dbg_object(dbg_object(t_ent).m_collision).m_box_z+dbg_object(dbg_object(t_ent).m_collision).m_box_d));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<971>";
		m_tf_box.p_Scale2(m_tf_scale);
		popErr();
		return 0;
	}
	public function p_CollisionSphereSetup(t_ent:c_TEntity,t_radius:Number,t_coll_obj:c_CollisionObject):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<958>";
		if(m_dst_entity!=t_ent){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<959>";
			m_dst_divSphere.p_RotateDivSpheres(t_ent,this,true);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<961>";
		m_dst_entity=t_ent;
		popErr();
		return 0;
	}
	internal var m_mesh_coll:c_MeshCollider=null;
	internal static var m_t_vec:c_Vector;
	public function p_CreateCollBox(t_box:c_Box,t_li:c_Line,t_radius:Number,t_scale:c_Vector):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<934>";
		t_box.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<935>";
		t_box.p_Update10(dbg_object(t_li).m_o);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<938>";
		t_radius=t_radius*1.001;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<941>";
		var t_delta:c_Vector=m_t_vec;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<942>";
		t_delta.p_Update(dbg_object(dbg_object(t_li).m_o).m_x+dbg_object(dbg_object(t_li).m_d).m_x+t_radius,dbg_object(dbg_object(t_li).m_o).m_y+dbg_object(dbg_object(t_li).m_d).m_y+t_radius,dbg_object(dbg_object(t_li).m_o).m_z+dbg_object(dbg_object(t_li).m_d).m_z+t_radius);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<943>";
		t_box.p_Update10(t_delta);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<944>";
		t_delta.p_Update(dbg_object(dbg_object(t_li).m_o).m_x+dbg_object(dbg_object(t_li).m_d).m_x-t_radius,dbg_object(dbg_object(t_li).m_o).m_y+dbg_object(dbg_object(t_li).m_d).m_y-t_radius,dbg_object(dbg_object(t_li).m_o).m_z+dbg_object(dbg_object(t_li).m_d).m_z-t_radius);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<945>";
		t_box.p_Update10(t_delta);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<948>";
		dbg_object(dbg_object(t_box).m_a).m_x*=dbg_object(t_scale).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<948>";
		dbg_object(dbg_object(t_box).m_a).m_y*=dbg_object(t_scale).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<948>";
		dbg_object(dbg_object(t_box).m_a).m_z*=dbg_object(t_scale).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<950>";
		dbg_object(dbg_object(t_box).m_b).m_x*=dbg_object(t_scale).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<950>";
		dbg_object(dbg_object(t_box).m_b).m_y*=dbg_object(t_scale).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<950>";
		dbg_object(dbg_object(t_box).m_b).m_z*=dbg_object(t_scale).m_z;
		popErr();
	}
	public function p_CollisionTriangleSetup(t_ent:c_TEntity,t_radius:Number,t_coll_obj:c_CollisionObject):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1004>";
		var t_mesh:c_TMesh=((t_ent) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1005>";
		if(t_mesh!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1006>";
			m_mesh_coll=dbg_object(t_mesh).m_col_tree.p_CreateMeshTree(t_mesh,8);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1010>";
		this.p_CreateCollBox(m_tf_box,m_tf_line,t_radius,m_inv_scale);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1019>";
		if(t_radius==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1022>";
			dbg_object(m_tf_radius).m_x=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1023>";
			m_mesh_coll.p_RayBoxSetup((new c_Line).m_Line_new2(dbg_object(m_tf_line).m_o.p_Multiply2(m_inv_scale),dbg_object(m_tf_line).m_d.p_Multiply2(m_inv_scale)));
		}
		popErr();
		return 0;
	}
	public function p_CollisionAABBSetup(t_ent:c_TEntity,t_radius:Number,t_coll_obj:c_CollisionObject):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<981>";
		m_tf_line=(new c_Line).m_Line_new2(dbg_object(m_coll_line).m_o,dbg_object(m_coll_line).m_d);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<983>";
		m_tf_box.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<984>";
		var t_xx:Number=dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<985>";
		var t_yy:Number=dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<986>";
		var t_zz:Number=-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<987>";
		dbg_object(m_tf_box).m_a.p_Overwrite2(dbg_object(dbg_object(t_ent).m_collision).m_box_x,dbg_object(dbg_object(t_ent).m_collision).m_box_y,dbg_object(dbg_object(t_ent).m_collision).m_box_z);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<988>";
		m_tf_box.p_Update10((new c_Vector).m_Vector_new(dbg_object(dbg_object(t_ent).m_collision).m_box_x+dbg_object(dbg_object(t_ent).m_collision).m_box_w,dbg_object(dbg_object(t_ent).m_collision).m_box_y+dbg_object(dbg_object(t_ent).m_collision).m_box_h,dbg_object(dbg_object(t_ent).m_collision).m_box_z+dbg_object(dbg_object(t_ent).m_collision).m_box_d));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<990>";
		m_tf_box.p_Scale2(m_tf_scale);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<991>";
		dbg_object(dbg_object(m_tf_box).m_a).m_x+=t_xx-t_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<991>";
		dbg_object(dbg_object(m_tf_box).m_a).m_y+=t_yy-t_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<991>";
		dbg_object(dbg_object(m_tf_box).m_a).m_z+=t_zz-t_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<992>";
		dbg_object(dbg_object(m_tf_box).m_b).m_x+=t_xx+t_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<992>";
		dbg_object(dbg_object(m_tf_box).m_b).m_y+=t_yy+t_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<992>";
		dbg_object(dbg_object(m_tf_box).m_b).m_z+=t_zz+t_radius;
		popErr();
		return 0;
	}
	public function p_CollisionSetup(t_ent:c_TEntity,t_coll_method:int,t_coll_obj:c_CollisionObject,t_offset2:c_Vector,t_pass2:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<823>";
		if(t_coll_method!=1 && t_coll_method!=4 && t_pass2==false){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<826>";
			var t_ex:Number=.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<826>";
			var t_ey:Number=.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<826>";
			var t_ez:Number=.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<827>";
			if(dbg_object(dbg_object(t_ent).m_collision).m_old_gsx==dbg_object(t_ent).m_gsx && dbg_object(dbg_object(t_ent).m_collision).m_old_gsy==dbg_object(t_ent).m_gsy && dbg_object(dbg_object(t_ent).m_collision).m_old_gsz==dbg_object(t_ent).m_gsz){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<828>";
				t_ex=dbg_object(dbg_object(t_ent).m_collision).m_old_igsx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<828>";
				t_ey=dbg_object(dbg_object(t_ent).m_collision).m_old_igsy;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<828>";
				t_ez=dbg_object(dbg_object(t_ent).m_collision).m_old_igsz;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<830>";
				t_ex=1.0/dbg_object(t_ent).m_gsx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<831>";
				t_ey=1.0/dbg_object(t_ent).m_gsy;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<832>";
				t_ez=1.0/dbg_object(t_ent).m_gsz;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<833>";
				dbg_object(dbg_object(t_ent).m_collision).m_old_gsx=dbg_object(t_ent).m_gsx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<833>";
				dbg_object(dbg_object(t_ent).m_collision).m_old_gsy=dbg_object(t_ent).m_gsy;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<833>";
				dbg_object(dbg_object(t_ent).m_collision).m_old_gsz=dbg_object(t_ent).m_gsz;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<834>";
				dbg_object(dbg_object(t_ent).m_collision).m_old_igsx=t_ex;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<834>";
				dbg_object(dbg_object(t_ent).m_collision).m_old_igsy=t_ey;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<834>";
				dbg_object(dbg_object(t_ent).m_collision).m_old_igsz=t_ez;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<837>";
			m_inv_scale.p_Overwrite2(t_ex,t_ey,t_ez);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<842>";
			dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,0)[dbg_index]=[dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,0)[dbg_index],0)[dbg_index]*t_ex,dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,1)[dbg_index],0)[dbg_index]*t_ey,-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,2)[dbg_index],0)[dbg_index]*t_ez,0.0];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<843>";
			dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,1)[dbg_index]=[dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,0)[dbg_index],1)[dbg_index]*t_ex,dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,1)[dbg_index],1)[dbg_index]*t_ey,-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,2)[dbg_index],1)[dbg_index]*t_ez,0.0];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<844>";
			dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,2)[dbg_index]=[-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,0)[dbg_index],2)[dbg_index]*t_ex,-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,1)[dbg_index],2)[dbg_index]*t_ey,dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,2)[dbg_index],2)[dbg_index]*t_ez,0.0];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<847>";
			dbg_array(dbg_object(m_renew2).m_grid,0)[dbg_index]=[dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,0)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,1)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,2)[dbg_index],0)[dbg_index],0.0];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<848>";
			dbg_array(dbg_object(m_renew2).m_grid,1)[dbg_index]=[dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,0)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,1)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,2)[dbg_index],1)[dbg_index],0.0];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<849>";
			dbg_array(dbg_object(m_renew2).m_grid,2)[dbg_index]=[dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,0)[dbg_index],2)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,1)[dbg_index],2)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(m_tform).m_m).m_grid,2)[dbg_index],2)[dbg_index],0.0];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<851>";
			if(m_y_scale!=1.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<853>";
				m_tform=m_y_tform.p_Multiply8(m_tform);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<863>";
		m_tf_scale.p_Overwrite2(dbg_object(t_ent).m_gsx,dbg_object(t_ent).m_gsy,dbg_object(t_ent).m_gsz);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<864>";
		m_tf_radius.p_Overwrite2(m_src_radius,m_src_radius,m_src_radius);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<866>";
		this.p_CreateCollLine(m_tf_line,t_ent,dbg_object(m_tform).m_m,t_offset2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<869>";
		if(t_coll_method==3){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<871>";
			this.p_CollisionBoxSetup(t_ent,m_src_radius,t_coll_obj);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<873>";
			if(t_coll_method==1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<875>";
				this.p_CollisionSphereSetup(t_ent,m_src_radius,t_coll_obj);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<877>";
				if(t_coll_method==2){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<879>";
					this.p_CollisionTriangleSetup(t_ent,m_src_radius,t_coll_obj);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<881>";
					if(t_coll_method==5){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<883>";
						this.p_CollisionTriangleSetup(t_ent,m_src_radius,t_coll_obj);
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<885>";
						if(t_coll_method==4){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<887>";
							this.p_CollisionAABBSetup(t_ent,m_src_radius,t_coll_obj);
						}
					}
				}
			}
		}
		popErr();
		return 0;
	}
	public function p_CollisionDetect(t_coll_obj:c_CollisionObject):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1037>";
		var t_res:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1040>";
		var t_1:int=m_coll_method;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1042>";
		if(t_1==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1044>";
			if(dbg_object(m_dst_divSphere).m_num>1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1045>";
				var t_hit:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1048>";
				for(var t_i:int=0;t_i<=dbg_object(m_dst_divSphere).m_num-1;t_i=t_i+1){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1050>";
					m_dst_radius=dbg_array(dbg_object(m_dst_divSphere).m_rad,t_i)[dbg_index];
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1051>";
					t_hit+=t_coll_obj.p_SphereCollide(m_tf_line,m_src_radius,m_tf_offset.p_Add2(dbg_object(dbg_array(dbg_object(m_dst_divSphere).m_pos,t_i)[dbg_index]).m_x,dbg_object(dbg_array(dbg_object(m_dst_divSphere).m_pos,t_i)[dbg_index]).m_y,dbg_object(dbg_array(dbg_object(m_dst_divSphere).m_pos,t_i)[dbg_index]).m_z),dbg_array(dbg_object(m_dst_divSphere).m_rad,t_i)[dbg_index],m_nullVec);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1055>";
				if(t_hit>0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1055>";
					t_res=1;
				}
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1059>";
				t_res=t_coll_obj.p_SphereCollide(m_tf_line,m_src_radius,m_tf_offset,m_dst_radius,m_nullVec);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1064>";
			if((t_res)!=0){
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1072>";
			if(t_1==2){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1078>";
				if((m_mesh_coll.p_CollideNodeAABB(m_tf_box,m_tf_radius,t_coll_obj,dbg_object(m_mesh_coll).m_tree,false))!=0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1082>";
					t_res=m_mesh_coll.p_TriNodeCollide(m_tf_box,m_tf_line,m_tf_radius,t_coll_obj,m_tf_scale,false);
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1085>";
					if((t_res)!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1087>";
						dbg_object(t_coll_obj).m_normal=m_renew2.p_Multiply2(dbg_object(t_coll_obj).m_normal);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1090>";
						dbg_object(t_coll_obj).m_col_coords=m_renew2.p_Multiply2(dbg_object(t_coll_obj).m_col_coords).p_Subtract(m_tf_offset);
					}
				}
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1096>";
				if(t_1==5){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1098>";
					if((m_mesh_coll.p_CollideNodeAABB(m_tf_box,m_tf_radius,t_coll_obj,dbg_object(m_mesh_coll).m_tree,false))!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1100>";
						t_res=m_mesh_coll.p_TriNodeCollide(m_tf_box,m_tf_line,m_tf_radius,t_coll_obj,m_tf_scale,true);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1103>";
						if((t_res)!=0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1105>";
							dbg_object(t_coll_obj).m_normal=m_renew2.p_Multiply2(dbg_object(t_coll_obj).m_normal);
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1108>";
							dbg_object(t_coll_obj).m_col_coords=m_renew2.p_Multiply2(dbg_object(t_coll_obj).m_col_coords).p_Subtract(m_tf_offset);
						}
					}
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1113>";
					if(t_1==3){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1117>";
						if((t_coll_obj.p_SphereBox(m_tf_line,m_tf_radius,m_tf_box,m_tf_scale))!=0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1119>";
							dbg_object(t_coll_obj).m_normal=m_renew2.p_Multiply2(dbg_object(t_coll_obj).m_normal);
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1121>";
							t_res=1;
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1124>";
							dbg_object(t_coll_obj).m_col_coords=m_renew2.p_Multiply2(dbg_object(t_coll_obj).m_col_coords).p_Subtract(m_tf_offset);
						}
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1134>";
						if(t_1==4){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1136>";
							if(m_tf_box.p_Overlaps2(dbg_object(m_tf_line).m_o.p_Add(dbg_object(m_tf_line).m_d)) || m_tf_box.p_Overlaps2(dbg_object(m_tf_line).m_o)){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1137>";
								t_res=1;
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1138>";
								dbg_object(t_coll_obj).m_col_coords.p_Overwrite3(dbg_object(m_tf_line).m_o.p_Add(dbg_object(m_tf_line).m_d));
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1139>";
								dbg_object(t_coll_obj).m_time=0.1;
							}else{
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1142>";
								var t_midvec:c_Vector=dbg_object(m_tf_line).m_o.p_Add(dbg_object(m_tf_line).m_d.p_Multiply5(0.5));
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1143>";
								if(m_tf_box.p_Overlaps2(t_midvec)){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1144>";
									t_res=1;
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1145>";
									dbg_object(t_coll_obj).m_col_coords.p_Overwrite3(t_midvec);
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1146>";
									dbg_object(t_coll_obj).m_time=0.05;
								}
							}
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1151>";
							if((t_res)!=0){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1152>";
								var t_norm:c_Vector=null;
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1153>";
								var t_cen:c_Vector=m_tf_box.p_Center();
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1154>";
								var t_nx:Number=bb_math_Abs2(dbg_object(dbg_object(m_tf_line).m_d).m_x);
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1155>";
								var t_ny:Number=bb_math_Abs2(dbg_object(dbg_object(m_tf_line).m_d).m_y);
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1156>";
								var t_nz:Number=bb_math_Abs2(dbg_object(dbg_object(m_tf_line).m_d).m_z);
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1158>";
								if(t_nx>t_ny && t_nx>t_nz){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1159>";
									t_norm=(new c_Vector).m_Vector_new(-bb_math_Sgn2(dbg_object(dbg_object(m_tf_line).m_d).m_x),0.0,0.0);
								}else{
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1161>";
									if(t_ny>t_nx && t_ny>t_nz){
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1162>";
										t_norm=(new c_Vector).m_Vector_new(0.0,-bb_math_Sgn2(dbg_object(dbg_object(m_tf_line).m_d).m_y),0.0);
									}else{
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1164>";
										if(t_nz>t_nx && t_nz>t_ny){
											_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1165>";
											t_norm=(new c_Vector).m_Vector_new(0.0,0.0,-bb_math_Sgn2(dbg_object(dbg_object(m_tf_line).m_d).m_z));
										}else{
											_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1168>";
											t_norm=(new c_Vector).m_Vector_new(-bb_math_Sgn2(dbg_object(dbg_object(m_tf_line).m_d).m_x),-bb_math_Sgn2(dbg_object(dbg_object(m_tf_line).m_d).m_y),-bb_math_Sgn2(dbg_object(dbg_object(m_tf_line).m_d).m_z));
										}
									}
								}
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1172>";
								dbg_object(t_coll_obj).m_normal=t_norm;
							}
						}
					}
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1187>";
		popErr();
		return t_res;
	}
	public function p_DivSpheresCollisionDetect(t_ent:c_TEntity,t_ent2:c_TEntity,t_c_method:int,t_coll_obj:c_CollisionObject):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1194>";
		m_coll_method=t_c_method;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1196>";
		var t_mesh:c_TMesh=((t_ent) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1197>";
		if(!((t_mesh)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1197>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1199>";
		var t_hit:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1199>";
		var t_total:int=dbg_object(m_src_divSphere).m_num;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1200>";
		var t_skip:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1202>";
		var t_line_o:c_Vector=dbg_object(m_coll_line).m_o.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1203>";
		var t_line_d:c_Vector=m_dv.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1205>";
		var t_temp_radius:Number=m_src_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1206>";
		var t_finalNormal:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1207>";
		var t_finalCoord:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1208>";
		var t_finalRad:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1209>";
		var t_finalDiv:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1210>";
		var t_finalPos:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1211>";
		var t_ctime:Number=99999.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1215>";
		for(var t_i:int=0;t_i<=t_total-1;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1220>";
			var t_hh:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1222>";
			m_src_radius=dbg_array(dbg_object(m_src_divSphere).m_rad,t_i)[dbg_index]*1.001;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1223>";
			dbg_object(m_src_divSphere).m_offset.p_Overwrite2(dbg_object(dbg_array(dbg_object(m_src_divSphere).m_pos,t_i)[dbg_index]).m_x,dbg_object(dbg_array(dbg_object(m_src_divSphere).m_pos,t_i)[dbg_index]).m_y,dbg_object(dbg_array(dbg_object(m_src_divSphere).m_pos,t_i)[dbg_index]).m_z);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1229>";
			this.p_CollisionSetup(t_ent2,t_c_method,t_coll_obj,m_nullVec,t_skip);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1231>";
			t_hh=this.p_CollisionDetect(t_coll_obj);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1234>";
			if(((t_hh)!=0) && dbg_object(t_coll_obj).m_time<t_ctime){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1235>";
				t_ctime=dbg_object(t_coll_obj).m_time;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1239>";
				t_finalNormal=dbg_object(t_coll_obj).m_normal.p_Copy();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1241>";
				t_finalCoord=dbg_object(t_coll_obj).m_col_coords.p_Copy();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1242>";
				t_finalRad=dbg_array(dbg_object(m_src_divSphere).m_rad,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1243>";
				t_finalDiv=dbg_object(m_src_divSphere).m_offset.p_Copy();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1244>";
				t_finalPos=dbg_object(t_coll_obj).m_col_pos.p_Copy();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1246>";
				t_hit=1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1252>";
			t_skip=true;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1258>";
		if(t_hit>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1260>";
			t_hit=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1261>";
			dbg_object(t_coll_obj).m_normal=t_finalNormal;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1262>";
			dbg_object(t_coll_obj).m_col_coords=t_finalCoord;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1264>";
			m_hitDivRadius=t_finalRad;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1265>";
			dbg_object(m_src_divSphere).m_offset=t_finalDiv;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1266>";
			m_hitDivOffset.p_Overwrite3(t_finalDiv);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1267>";
			dbg_object(t_coll_obj).m_time=t_ctime;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1271>";
		m_src_radius=t_temp_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1273>";
		popErr();
		return t_hit;
	}
	public function p_RegisterHitPlane(t_coords:c_Vector,t_normal:c_Vector):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1285>";
		m_hits+=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1286>";
		if(m_hits>4){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1289>";
		if(m_n_hit>4){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1291>";
		dbg_array(m_planes,m_n_hit)[dbg_index]=(new c_Plane).m_Plane_new2(t_coords,t_normal);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1292>";
		dbg_array(m_col_points,m_n_hit)[dbg_index]=t_coords.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1293>";
		m_n_hit+=1;
		popErr();
	}
	public function p_CollisionResponse(t_col_obj:c_CollisionObject,t_response:int,t_radius:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1309>";
		if(m_hits>=10){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1309>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1312>";
		var t_new_offset:c_Vector=dbg_object(t_col_obj).m_normal.p_Multiply5(t_radius*1.001);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1313>";
		var t_new_coords:c_Vector=dbg_object(t_col_obj).m_col_coords.p_Add(t_new_offset).p_Subtract(m_hitDivOffset);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1324>";
		var t_coll_plane:c_Plane=(new c_Plane).m_Plane_new2(t_new_coords,dbg_object(t_col_obj).m_normal);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1329>";
		var t_adv:c_Vector=m_dv.p_Copy().p_Add(t_new_offset);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1332>";
		if(t_response==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1333>";
			m_dv.p_Overwrite3(m_sv);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1334>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1339>";
		m_sv.p_Overwrite3(t_new_coords);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1342>";
		var t_nv:c_Vector=t_coll_plane.p_Nearest(t_adv);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1349>";
		if(m_n_hit>0 && m_n_hit<4){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1354>";
			var t_pn2:c_Vector=dbg_object(t_coll_plane).m_n.p_Add(dbg_object(dbg_array(m_planes,m_n_hit-1)[dbg_index]).m_n).p_Multiply5(0.5).p_Normalize();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1355>";
			var t_c2:c_Vector=dbg_object(t_col_obj).m_col_coords.p_Add(dbg_array(m_col_points,m_n_hit-1)[dbg_index]).p_Multiply5(0.5);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1356>";
			var t_pl2:c_Plane=(new c_Plane).m_Plane_new2(t_c2.p_Add(t_new_offset.p_Multiply5(1.001)).p_Subtract(m_hitDivOffset),t_pn2);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1358>";
			t_nv=t_pl2.p_Nearest(t_adv);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1359>";
			dbg_object(t_col_obj).m_normal=t_pn2;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1360>";
			dbg_object(t_col_obj).m_col_coords=t_c2;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1364>";
			if(m_n_hit>3){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1366>";
				t_nv=m_sv.p_Add(dbg_object(t_col_obj).m_normal.p_Multiply5(0.001));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1367>";
				dbg_object(t_col_obj).m_col_coords=dbg_object(t_col_obj).m_col_coords.p_Add(dbg_object(t_col_obj).m_normal.p_Multiply5(0.001));
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1433>";
		var t_dd:c_Vector=t_nv.p_Subtract(t_adv);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1439>";
		var t_d:Number=t_dd.p_Dot(t_dd);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1440>";
		if(t_d<0.00001){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1440>";
			m_dv.p_Overwrite3(m_sv);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1440>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1442>";
		if(t_response==2){
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1444>";
			if(t_response==3){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1446>";
				t_nv.p_Overwrite2(dbg_object(t_nv).m_x,dbg_object(dbg_object(m_coll_line).m_o).m_y,dbg_object(t_nv).m_z);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1447>";
				dbg_object(m_sv).m_y=dbg_object(dbg_object(m_coll_line).m_o).m_y;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1454>";
		m_dv.p_Overwrite3(t_nv);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1455>";
		dbg_object(m_coll_line).m_o.p_Overwrite3(m_sv);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1456>";
		dbg_object(m_coll_line).m_d.p_Overwrite3(m_dv.p_Subtract(m_sv));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1462>";
		popErr();
		return 1;
	}
	public function p_CollisionFinal(t_coll:c_CollisionObject,t_response:int):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1469>";
		if(t_response==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1469>";
			popErr();
			return false;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1471>";
		if((m_hits)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1473>";
			if(m_hits<10){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1474>";
				dbg_object(m_dv).m_y*=m_inv_y_scale;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1475>";
				dbg_object(t_coll).m_col_pos.p_Overwrite3(m_dv);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1480>";
				dbg_object(t_coll).m_col_pos.p_Overwrite3(m_panic);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1483>";
			popErr();
			return true;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1486>";
		popErr();
		return false;
	}
	public static function m_UpdateCollisions():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<627>";
		var t_coll_obj:c_CollisionObject=(new c_CollisionObject).m_CollisionObject_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<629>";
		m_col_info.p_Clear();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<632>";
		for(var t_i:int=0;t_i<100;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<635>";
			if(dbg_array(c_TCollisionPair.m_ent_lists,t_i)[dbg_index]==null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<635>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<638>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<638>";
			var t_:c_Enumerator2=dbg_array(c_TCollisionPair.m_ent_lists,t_i)[dbg_index].p_ObjectEnumerator();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<638>";
			while(t_.p_HasNext()){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<638>";
				var t_ent:c_TEntity=t_.p_NextObject();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<641>";
				dbg_object(t_ent).m_collision.p_ClearImpact();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<644>";
				if(t_ent.p_Hidden()==true){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<644>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<647>";
				m_col_info.p_UpdateSourceSphere(t_ent);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<650>";
				if(dbg_object(t_ent).m_collision.p_MoveTest(t_ent)==false){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<650>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<652>";
				dbg_object(m_col_info).m_vec_a.p_Update(dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index],-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index]);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<653>";
				dbg_object(m_col_info).m_vec_b.p_Update(dbg_object(dbg_object(t_ent).m_collision).m_old_px,dbg_object(dbg_object(t_ent).m_collision).m_old_py,dbg_object(dbg_object(t_ent).m_collision).m_old_pz);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<654>";
				var t_sc:Number=bb_math_Max2(bb_math_Max2(bb_math_Abs2(dbg_object(t_ent).m_gsx),bb_math_Abs2(dbg_object(t_ent).m_gsy)),bb_math_Abs2(dbg_object(t_ent).m_gsz));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<656>";
				dbg_object(m_col_info).m_vec_c.p_Update(dbg_object(dbg_object(t_ent).m_collision).m_radius_x*t_sc,dbg_object(dbg_object(t_ent).m_collision).m_radius_y*t_sc,dbg_object(dbg_object(t_ent).m_collision).m_radius_x*t_sc);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<657>";
				dbg_object(t_ent).m_collision.p_SetOldPosition(t_ent,dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index],-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index]);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<660>";
				m_col_info.p_ClearHitPlanes();
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<661>";
				m_col_info.p_UpdateRay(dbg_object(m_col_info).m_vec_b,dbg_object(m_col_info).m_vec_a,dbg_object(m_col_info).m_vec_c);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<664>";
				if(((t_ent) as c_TMesh)!=null){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<665>";
					dbg_object(m_col_info).m_src_divSphere.p_RotateDivSpheres(t_ent,m_col_info,false);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<668>";
				var t_response:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<669>";
				var t_obj_time:Number=9999999.9;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<671>";
				var t_pass2:Boolean=false;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<672>";
				var t_hit:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<673>";
				dbg_object(m_col_info).m_col_passes=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<674>";
				var t_original_src_radius:Number=dbg_object(m_col_info).m_src_radius;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<677>";
				var t_radvec:c_Vector=(new c_Vector).m_Vector_new(dbg_object(m_col_info).m_src_radius,dbg_object(m_col_info).m_src_radius,dbg_object(m_col_info).m_src_radius);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<680>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<682>";
					var t_ent2_hit:c_TEntity=null;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<683>";
					t_coll_obj.p_Clear();
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<688>";
					dbg_object(t_coll_obj).m_time=dbg_object(dbg_object(m_col_info).m_coll_line).m_o.p_DistanceSquared2(t_radvec)*1.1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<690>";
					m_starttime=dbg_object(t_coll_obj).m_time;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<692>";
					if(dbg_object(dbg_object(t_ent).m_collision).m_radius_x==0.0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<692>";
						dbg_object(t_coll_obj).m_time=1.0;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<695>";
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<695>";
					var t_2:c_Enumerator7=c_TCollisionPair.m_list.p_ObjectEnumerator();
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<695>";
					while(t_2.p_HasNext()){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<695>";
						var t_col_pair:c_TCollisionPair=t_2.p_NextObject();
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<697>";
						if(dbg_object(t_col_pair).m_src_type==t_i){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<700>";
							if(dbg_array(c_TCollisionPair.m_ent_lists,dbg_object(t_col_pair).m_des_type)[dbg_index]==null){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<700>";
								continue;
							}
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<704>";
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<704>";
							var t_3:c_Enumerator2=dbg_array(c_TCollisionPair.m_ent_lists,dbg_object(t_col_pair).m_des_type)[dbg_index].p_ObjectEnumerator();
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<704>";
							while(t_3.p_HasNext()){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<704>";
								var t_ent2:c_TEntity=t_3.p_NextObject();
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<707>";
								if(t_ent2.p_Hidden()==true){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<707>";
									continue;
								}
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<709>";
								if(t_ent==t_ent2){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<709>";
									continue;
								}
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<714>";
								m_col_info.p_UpdateDestShape(t_ent2);
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<718>";
								if(c_CollisionObject.m_QuickBoundsTest(m_col_info,t_ent2)){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<720>";
									dbg_object(m_col_info).m_coll_method=dbg_object(t_col_pair).m_col_method;
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<724>";
									if(dbg_object(dbg_object(m_col_info).m_src_divSphere).m_num<=1){
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<726>";
										m_col_info.p_CollisionSetup(t_ent2,dbg_object(t_col_pair).m_col_method,t_coll_obj,m_nullVec,false);
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<727>";
										t_hit=m_col_info.p_CollisionDetect(t_coll_obj);
									}else{
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<731>";
										t_hit=m_col_info.p_DivSpheresCollisionDetect(t_ent,t_ent2,dbg_object(t_col_pair).m_col_method,t_coll_obj);
									}
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<735>";
									if((t_hit)!=0){
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<736>";
										m_col_info.p_RegisterHitPlane(dbg_object(t_coll_obj).m_col_coords,dbg_object(t_coll_obj).m_normal);
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<738>";
										t_ent2_hit=t_ent2;
										_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<739>";
										t_response=dbg_object(t_col_pair).m_response;
									}
								}
							}
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<754>";
					if(t_ent2_hit!=null){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<765>";
						dbg_object(t_ent).m_collision.p_CreateImpact(t_ent2_hit,t_coll_obj);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<766>";
						var t_res:int=1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<769>";
						if(dbg_object(dbg_object(m_col_info).m_src_divSphere).m_num>1){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<770>";
							t_res=m_col_info.p_CollisionResponse(t_coll_obj,t_response,dbg_object(m_col_info).m_hitDivRadius);
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<772>";
							t_res=m_col_info.p_CollisionResponse(t_coll_obj,t_response,dbg_object(m_col_info).m_src_radius);
						}
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<775>";
						if(t_res==0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<775>";
							break;
						}
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<779>";
						break;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<786>";
					dbg_object(m_col_info).m_col_passes+=1;
				}while(!(false));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<793>";
				var t_hits:int=((m_col_info.p_CollisionFinal(t_coll_obj,t_response))?1:0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<795>";
				if((t_hits)!=0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<797>";
					t_ent.p_PositionEntity(dbg_object(dbg_object(t_coll_obj).m_col_pos).m_x,dbg_object(dbg_object(t_coll_obj).m_col_pos).m_y,dbg_object(dbg_object(t_coll_obj).m_col_pos).m_z,1);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<802>";
				dbg_object(t_ent).m_collision.p_SetOldPosition(t_ent,dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],1)[dbg_index],-dbg_array(dbg_array(dbg_object(dbg_object(t_ent).m_mat).m_grid,3)[dbg_index],2)[dbg_index]);
			}
		}
		popErr();
		return 0;
	}
}
class c_CollisionObject extends Object{
	public function m_CollisionObject_new():c_CollisionObject{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1499>";
		popErr();
		return this;
	}
	internal var m_time:Number=99999999.0;
	internal var m_normal:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_surface:int=0;
	internal var m_index:int=0;
	internal var m_obj_time:Number=.0;
	internal var m_col_coords:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_col_normal:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_col_time:int=0;
	internal var m_col_surface:int=0;
	internal var m_col_index:int=0;
	internal var m_col_pos:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_col_box:c_Box=(new c_Box).m_Box_new();
	public function p_Clear():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1557>";
		m_time=99999999.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1558>";
		m_normal=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1559>";
		m_surface=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1560>";
		m_index=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1561>";
		m_obj_time=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1562>";
		m_col_coords=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1563>";
		m_col_normal=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1564>";
		m_col_time=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1565>";
		m_col_surface=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1566>";
		m_col_index=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1567>";
		m_col_pos=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1568>";
		m_col_box=(new c_Box).m_Box_new();
		popErr();
	}
	public static function m_QuickBoundsTest(t_col:c_CollisionInfo,t_ent2:c_TEntity):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1614>";
		var t_ds:Number=dbg_object(t_col).m_ray_length*0.5+dbg_object(t_col).m_src_radius+dbg_object(t_col).m_src_radius+dbg_object(t_col).m_dst_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1616>";
		var t_:Boolean=dbg_object(t_col).m_dst_pos.p_DistanceSquared2(dbg_object(t_col).m_ray_center)<t_ds*t_ds;
		popErr();
		return t_;
	}
	internal var m_coll_u:Number=.0;
	internal var m_coll_v:Number=.0;
	public function p_Update8(t_line:c_Line,t_t:Number,t_n:c_Vector,t_u:Number,t_v:Number,t_intersect:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1574>";
		if(t_t>m_time){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1574>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1576>";
		var t_p:c_Plane=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1578>";
		if((t_intersect)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1584>";
			t_p=(new c_Plane).m_Plane_new2(t_intersect,t_n);
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1588>";
			t_p=(new c_Plane).m_Plane_new2(t_line.p_Multiply5(t_t),t_n);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1589>";
			if(dbg_object(t_p).m_n.p_Dot(dbg_object(t_line).m_o)+dbg_object(t_p).m_d<-0.00001){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1589>";
				popErr();
				return 0;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1594>";
		if(dbg_object(t_p).m_n.p_Dot(dbg_object(t_line).m_d)>-0.00001){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1594>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1600>";
		if((t_intersect)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1600>";
			m_col_coords.p_Overwrite3(t_intersect);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1601>";
		m_time=t_t;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1602>";
		m_normal.p_Overwrite3(t_n);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1603>";
		m_coll_u=t_u;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1604>";
		m_coll_v=t_v;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1606>";
		popErr();
		return 1;
	}
	public function p_SphereCollide(t_line:c_Line,t_s_radius:Number,t_dest:c_Vector,t_d_radius:Number,t_offset2:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1684>";
		var t_radius:Number=t_s_radius+t_d_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1686>";
		var t_dd:c_Vector=t_dest.p_Subtract(dbg_object(t_line).m_o);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1687>";
		var t_ld:c_Vector=dbg_object(t_line).m_d.p_Normalize();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1690>";
		var t_b:Number=t_ld.p_Dot(t_dd);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1692>";
		if(t_b<0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1692>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1695>";
		var t_c:Number=t_dd.p_Dot(t_dd);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1696>";
		var t_d:Number=t_b*t_b-t_c+t_radius*t_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1697>";
		if(t_d<0.00001){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1697>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1701>";
		t_d=Math.sqrt(t_d);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1702>";
		var t_f1:Number=-t_b+t_d;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1703>";
		var t_f2:Number=-t_b-t_d;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1705>";
		var t_f:Number=t_f1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1706>";
		if(t_f2>t_f1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1706>";
			t_f=t_f2;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1711>";
		var t_i:c_Vector=t_ld.p_Multiply5(-t_f);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1712>";
		var t_t:Number=t_i.p_DistanceSquared();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1717>";
		if(t_t>m_time){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1717>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1721>";
		var t_hh:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1723>";
		if(t_t>dbg_object(t_line).m_d.p_DistanceSquared() && t_hh==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1723>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1727>";
		var t_nvec:c_Vector=t_i.p_Add(dbg_object(t_line).m_o).p_Subtract(t_dest).p_Normalize();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1732>";
		var t_:int=this.p_Update8(t_line,t_t,t_nvec,0.0,0.0,t_dest.p_Add(t_nvec.p_Multiply5(t_d_radius)));
		popErr();
		return t_;
	}
	public function p_SphereTriangle(t_li:c_Line,t_tf_radius:c_Vector,t_v0:c_Vector,t_v1:c_Vector,t_v2:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1861>";
		var t_u:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1861>";
		var t_v:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1861>";
		var t_n:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1862>";
		var t_dst:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1862>";
		var t_w0:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1862>";
		var t_w:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1863>";
		var t_i:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1864>";
		var t_ix:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1865>";
		var t_r:Number=-1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1865>";
		var t_a:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1865>";
		var t_b:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1865>";
		var t_dotradius:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1866>";
		var t_ru:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1866>";
		var t_rv:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1867>";
		var t_beneath:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1871>";
		t_u=t_v1.p_Subtract(t_v0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1872>";
		t_v=t_v2.p_Subtract(t_v0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1873>";
		t_n=t_u.p_Cross(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1874>";
		if(dbg_object(t_n).m_x==0.0 && dbg_object(t_n).m_y==0.0 && dbg_object(t_n).m_z==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1874>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1875>";
		t_n=t_n.p_Normalize();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1880>";
		var t_src:c_Vector=dbg_object(t_li).m_o.p_Subtract(t_v0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1881>";
		var t_n_radius:Number=dbg_object(t_tf_radius).m_x*dbg_object(t_tf_radius).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1883>";
		var t_o_len:Number=t_n.p_Dot(t_src);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1885>";
		if(t_o_len<0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1885>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1888>";
		t_i=dbg_object(t_li).m_o.p_Subtract(t_n.p_Multiply5(t_o_len));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1889>";
		var t_o_radius:Number=t_i.p_DistanceSquared2(dbg_object(t_li).m_o);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1892>";
		var t_diff:Number=t_o_radius-t_n_radius;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1894>";
		if(t_diff>m_time){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1894>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1897>";
		if(t_diff<0.0 && t_diff>-t_n_radius-0.000001){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1900>";
			t_beneath=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1902>";
			t_r=t_o_radius;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1906>";
			t_ix=dbg_object(t_li).m_o;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1911>";
			var t_nr:Number=dbg_object(t_tf_radius).m_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1912>";
			t_a=t_o_len;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1913>";
			t_b=-dbg_object(t_li).m_d.p_Dot(t_n);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1914>";
			var t_b2:Number=t_b+bb_math_Sgn2(t_b)*t_nr;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1916>";
			var t_r2:Number=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1917>";
			if(t_b2==0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1917>";
				popErr();
				return 0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1919>";
			t_r2=t_a/t_b2;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1921>";
			if(t_r2<0.0 || t_r2>1.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1921>";
				popErr();
				return 0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1923>";
			t_ix=dbg_object(t_li).m_o.p_Add(dbg_object(t_li).m_d.p_Multiply5(t_r2));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1924>";
			t_i=t_ix.p_Subtract(t_n.p_Multiply5(t_ix.p_Subtract(t_v0).p_Dot(t_n)));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1928>";
			t_r=dbg_object(t_li).m_o.p_DistanceSquared2(t_ix);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1934>";
		if(t_r>m_time){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1934>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1939>";
		var t_uu:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1939>";
		var t_uv:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1939>";
		var t_vv:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1939>";
		var t_wu:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1939>";
		var t_wv:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1939>";
		var t_D:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1940>";
		t_uu=t_u.p_Dot(t_u);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1941>";
		t_vv=t_v.p_Dot(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1943>";
		t_w=t_i.p_Subtract(t_v0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1950>";
		if(dbg_object(t_w).m_x>0.0 && dbg_object(t_w).m_y>0.0 && dbg_object(t_w).m_z>0.0 && dbg_object(t_w).m_x>dbg_object(t_u).m_x && dbg_object(t_w).m_y>dbg_object(t_u).m_y && dbg_object(t_w).m_z>dbg_object(t_u).m_z && dbg_object(t_w).m_x>dbg_object(t_v).m_x && dbg_object(t_w).m_y>dbg_object(t_v).m_y && dbg_object(t_w).m_z>dbg_object(t_v).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1950>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1953>";
		if(dbg_object(t_w).m_x<0.0 && dbg_object(t_w).m_y<0.0 && dbg_object(t_w).m_z<0.0 && dbg_object(t_w).m_x<dbg_object(t_u).m_x && dbg_object(t_w).m_y<dbg_object(t_u).m_y && dbg_object(t_w).m_z<dbg_object(t_u).m_z && dbg_object(t_w).m_x<dbg_object(t_v).m_x && dbg_object(t_w).m_y<dbg_object(t_v).m_y && dbg_object(t_w).m_z<dbg_object(t_v).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1953>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1955>";
		t_uv=t_u.p_Dot(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1956>";
		t_wu=t_w.p_Dot(t_u);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1957>";
		t_wv=t_w.p_Dot(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1958>";
		t_D=1.0/(t_uv*t_uv-t_uu*t_vv);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1962>";
		var t_s:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1962>";
		var t_t:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1962>";
		var t_out:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1962>";
		var t_bb:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1964>";
		t_s=(t_uv*t_wv-t_vv*t_wu)*t_D;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1965>";
		if(t_s<0.0 || t_s>1.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1967>";
			t_out=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1971>";
		t_t=(t_uv*t_wu-t_uu*t_wv)*t_D;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1973>";
		if(t_t<0.0 || t_s+t_t>1.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1975>";
			t_out=t_out+1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1980>";
		if(t_out>0 && ((dbg_object(t_tf_radius).m_x)!=0.0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1983>";
			if(t_s+t_t>1.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1984>";
				t_bb=t_ix.p_PointOnSegment(t_v1,t_v2);
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1985>";
				if(t_t<0.0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1986>";
					t_bb=t_ix.p_PointOnSegment(t_v0,t_v1);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1988>";
					t_bb=t_ix.p_PointOnSegment(t_v0,t_v2);
				}
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1993>";
			var t_nr2:Number=t_ix.p_DistanceSquared2(t_bb)*1.001;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1995>";
			var t_offset:Number=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1997>";
			if(t_nr2>t_n_radius+t_offset || t_nr2>m_time){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1997>";
				popErr();
				return 0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2000>";
			t_r=t_nr2-t_offset;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2002>";
			var t_ld:c_Vector=dbg_object(t_li).m_d.p_Multiply5(0.1);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2004>";
			t_n=t_ix.p_Subtract(t_bb).p_Normalize();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2005>";
			t_bb=t_bb.p_Subtract(t_n.p_Multiply5(0.01));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2008>";
			t_i=t_bb;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2014>";
			if(t_out>0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2016>";
				popErr();
				return 0;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<2024>";
		var t_:int=this.p_Update8(t_li,t_r,t_n,t_s,t_t,t_i);
		popErr();
		return t_;
	}
	public function p_RayTriangle(t_li:c_Line,t_v0:c_Vector,t_v1:c_Vector,t_v2:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1774>";
		var t_u:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1774>";
		var t_v:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1774>";
		var t_n:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1775>";
		var t_w:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1776>";
		var t_i:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1777>";
		var t_r:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1777>";
		var t_a:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1777>";
		var t_b:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1777>";
		var t_radius:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1781>";
		t_u=t_v1.p_Subtract(t_v0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1782>";
		t_v=t_v2.p_Subtract(t_v0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1783>";
		t_n=t_u.p_Cross(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1784>";
		if(dbg_object(t_n).m_x==0.0 && dbg_object(t_n).m_y==0.0 && dbg_object(t_n).m_z==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1784>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1788>";
		t_a=dbg_object(t_li).m_o.p_Subtract(t_v0).p_Dot(t_n);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1789>";
		t_b=-dbg_object(t_li).m_d.p_Dot(t_n);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1794>";
		if(t_b==0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1795>";
			if(t_a==0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1796>";
				t_r=0.0;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1798>";
				popErr();
				return 0;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1803>";
			t_r=t_a/t_b;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1804>";
			t_i.p_Overwrite2(dbg_object(dbg_object(t_li).m_o).m_x+dbg_object(dbg_object(t_li).m_d).m_x*t_r,dbg_object(dbg_object(t_li).m_o).m_y+dbg_object(dbg_object(t_li).m_d).m_y*t_r,dbg_object(dbg_object(t_li).m_o).m_z+dbg_object(dbg_object(t_li).m_d).m_z*t_r);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1809>";
		if(t_r>m_time){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1809>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1813>";
		var t_uu:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1813>";
		var t_uv:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1813>";
		var t_vv:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1813>";
		var t_wu:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1813>";
		var t_wv:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1813>";
		var t_D:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1814>";
		t_uu=t_u.p_Dot(t_u);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1815>";
		t_vv=t_v.p_Dot(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1817>";
		t_w=t_i.p_Subtract(t_v0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1819>";
		var t_ids:Number=t_w.p_DistanceSquared();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1820>";
		if(t_ids>t_uu && t_ids>t_vv){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1820>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1822>";
		t_uv=t_u.p_Dot(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1823>";
		t_wu=t_w.p_Dot(t_u);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1824>";
		t_wv=t_w.p_Dot(t_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1825>";
		t_D=1.0/(t_uv*t_uv-t_uu*t_vv);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1828>";
		var t_s:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1828>";
		var t_t:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1828>";
		var t_out:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1828>";
		var t_diff:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1829>";
		t_s=(t_uv*t_wv-t_vv*t_wu)*t_D;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1830>";
		if(t_s<0.0 || t_s>1.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1831>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1834>";
		t_t=(t_uv*t_wu-t_uu*t_wv)*t_D;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1836>";
		if(t_t<0.0 || t_s+t_t>1.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1837>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1843>";
		var t_:int=this.p_Update8(t_li,t_r,t_n,t_s,t_t,t_i.p_Copy());
		popErr();
		return t_;
	}
	internal static var m_BOXQUADS:Array;
	public function p_SphereBox(t_li:c_Line,t_s_radvec:c_Vector,t_box:c_Box,t_scale:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1745>";
		var t_hit:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1752>";
		for(var t_n:int=0;t_n<=23;t_n=t_n+4){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1754>";
			var t_v0:c_Vector=t_box.p_Corner(dbg_array(m_BOXQUADS,t_n)[dbg_index]);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1755>";
			var t_v1:c_Vector=t_box.p_Corner(dbg_array(m_BOXQUADS,t_n+1)[dbg_index]);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1756>";
			var t_v2:c_Vector=t_box.p_Corner(dbg_array(m_BOXQUADS,t_n+2)[dbg_index]);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1757>";
			var t_v3:c_Vector=t_box.p_Corner(dbg_array(m_BOXQUADS,t_n+3)[dbg_index]);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1759>";
			t_hit=t_hit|this.p_SphereTriangle(t_li,t_s_radvec,t_v0,t_v1,t_v2)|this.p_SphereTriangle(t_li,t_s_radvec,t_v0,t_v2,t_v3);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1763>";
		if((t_hit)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1763>";
			m_col_box=t_box.p_Copy();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<1765>";
		popErr();
		return t_hit;
	}
}
class c_TransformMat extends Object{
	internal var m_m:c_Matrix=null;
	internal var m_v:c_Vector=null;
	public function m_TransformMat_new():c_TransformMat{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<342>";
		m_m=(new c_Matrix).m_Matrix_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<343>";
		m_v=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		popErr();
		return this;
	}
	public function m_TransformMat_new2(t_mm:c_Matrix,t_vv:c_Vector):c_TransformMat{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<347>";
		m_v=t_vv.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<348>";
		m_m=t_mm.p_Copy();
		popErr();
		return this;
	}
	public function p_Multiply2(t_q:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<380>";
		var t_:c_Vector=m_m.p_Multiply2(t_q).p_Add(m_v);
		popErr();
		return t_;
	}
	public function p_Multiply3(t_q:c_Line):c_Line{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<385>";
		var t_t:c_Vector=m_m.p_Multiply2(dbg_object(t_q).m_o).p_Add(m_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<386>";
		var t_:c_Line=(new c_Line).m_Line_new2(t_t,m_m.p_Multiply2(dbg_object(t_q).m_o.p_Add(dbg_object(t_q).m_d)).p_Add(m_v).p_Subtract(t_t));
		popErr();
		return t_;
	}
	public function p_Multiply7(t_q:c_Box):c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<391>";
		var t_b:c_Box=(new c_Box).m_Box_new2(m_m.p_Multiply2(t_q.p_Corner(0)).p_Add(m_v));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<392>";
		for(var t_k:int=1;t_k<=7;t_k=t_k+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<393>";
			t_b.p_Update10(m_m.p_Multiply2(t_q.p_Corner(t_k)).p_Add(m_v));
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<395>";
		popErr();
		return t_b;
	}
	public function p_Multiply8(t_q:c_TransformMat):c_TransformMat{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<400>";
		var t_t:c_TransformMat=(new c_TransformMat).m_TransformMat_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<401>";
		dbg_object(t_t).m_m=m_m.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<402>";
		var t_temp_m:c_Matrix=m_m.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<404>";
		dbg_object(t_t).m_m.p_Multiply(dbg_object(t_q).m_m);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<405>";
		dbg_object(t_t).m_v=t_temp_m.p_Multiply2(dbg_object(t_q).m_v).p_Add(m_v);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<406>";
		popErr();
		return t_t;
	}
}
class c_Plane extends Object{
	internal var m_n:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_d:Number=0.0;
	public function m_Plane_new(t_nn:c_Vector,t_dd:Number):c_Plane{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<91>";
		m_n=t_nn.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<92>";
		m_d=t_dd;
		popErr();
		return this;
	}
	public function m_Plane_new2(t_p:c_Vector,t_nn:c_Vector):c_Plane{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<97>";
		m_n=t_nn.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<98>";
		m_d=-m_n.p_Dot(t_p);
		popErr();
		return this;
	}
	public function m_Plane_new3(t_v0:c_Vector,t_v1:c_Vector,t_v2:c_Vector):c_Plane{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<104>";
		m_n=t_v1.p_Subtract(t_v0).p_Cross(t_v2.p_Subtract(t_v0)).p_Normalize();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<105>";
		m_d=-m_n.p_Dot(t_v0);
		popErr();
		return this;
	}
	public function m_Plane_new4():c_Plane{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<81>";
		popErr();
		return this;
	}
	public function p_Update9(t_nnx:Number,t_nny:Number,t_nnz:Number,t_dd:Number):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<109>";
		dbg_object(m_n).m_x=t_nnx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<109>";
		dbg_object(m_n).m_y=t_nny;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<109>";
		dbg_object(m_n).m_z=t_nnz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<110>";
		m_d=t_dd;
		popErr();
		return 0;
	}
	public function p_Distance(t_q:c_Vector):Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<149>";
		var t_:Number=m_n.p_Dot(t_q)+m_d;
		popErr();
		return t_;
	}
	public function p_Nearest(t_q:c_Vector):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<139>";
		var t_:c_Vector=t_q.p_Subtract(m_n.p_Multiply5(this.p_Distance(t_q)));
		popErr();
		return t_;
	}
}
class c_DivSphereInfo extends Object{
	public function m_DivSphereInfo_new():c_DivSphereInfo{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<295>";
		popErr();
		return this;
	}
	internal var m_offset:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	internal var m_pos:Array=[];
	internal var m_rad:Array=[];
	internal var m_num:int=0;
	public function p_Clear():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<303>";
		m_offset.p_Overwrite2(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<304>";
		m_pos=new_object_array(0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<305>";
		m_rad=new_number_array(0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<306>";
		m_num=0;
		popErr();
	}
	public function p_RotateDivSpheres(t_ent:c_TEntity,t_col_info:c_CollisionInfo,t_inverse:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<312>";
		m_num=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<313>";
		m_offset.p_Overwrite2(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<315>";
		var t_mesh:c_TMesh=((t_ent) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<316>";
		if(((t_mesh)!=null) && dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_p.length>1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<318>";
			var t_quickmat:c_Matrix=dbg_object(t_ent).m_mat.p_Copy();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<319>";
			dbg_array(dbg_array(dbg_object(t_quickmat).m_grid,3)[dbg_index],0)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<319>";
			dbg_array(dbg_array(dbg_object(t_quickmat).m_grid,3)[dbg_index],1)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<319>";
			dbg_array(dbg_array(dbg_object(t_quickmat).m_grid,3)[dbg_index],2)[dbg_index]=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<321>";
			if(t_inverse){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<321>";
				t_quickmat=t_quickmat.p_Inverse();
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<323>";
			if(!((m_pos).length!=0) || m_pos.length<dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_p.length){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<325>";
				m_pos=new_object_array(dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_p.length);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<326>";
				m_rad=new_number_array(dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_p.length);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<330>";
			var t_radmax:Number=bb_math_Max2(bb_math_Max2(dbg_object(t_ent).m_gsx,dbg_object(t_ent).m_gsy),dbg_object(t_ent).m_gsz);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<331>";
			for(var t_i:int=0;t_i<=dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_p.length-1;t_i=t_i+1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<334>";
				dbg_array(m_pos,t_i)[dbg_index]=t_quickmat.p_Multiply2(dbg_array(dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_p,t_i)[dbg_index]);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<335>";
				dbg_array(m_rad,t_i)[dbg_index]=dbg_array(dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_r,t_i)[dbg_index]*t_radmax;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<340>";
			m_num=dbg_object(dbg_object(t_mesh).m_col_tree).m_divSphere_p.length;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<342>";
			popErr();
			return m_num;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<347>";
		popErr();
		return 0;
	}
}
class c_TCollisionPair extends Object{
	internal static var m_ent_lists:Array;
	internal static var m_list:c_List10;
	internal var m_src_type:int=0;
	internal var m_des_type:int=0;
	internal var m_col_method:int=0;
	internal var m_response:int=0;
}
class c_TCollisionImpact extends Object{
	public function m_TCollisionImpact_new():c_TCollisionImpact{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcollision.monkey<186>";
		popErr();
		return this;
	}
	internal var m_x:Number=.0;
	internal var m_y:Number=.0;
	internal var m_z:Number=.0;
	internal var m_nx:Number=.0;
	internal var m_ny:Number=.0;
	internal var m_nz:Number=.0;
	internal var m_ent:c_TEntity=null;
	internal var m_surf:int=0;
	internal var m_tri:int=0;
}
internal function bb_math_Abs(t_x:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<46>";
	if(t_x>=0){
		_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<46>";
		popErr();
		return t_x;
	}
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<47>";
	var t_:int=-t_x;
	popErr();
	return t_;
}
internal function bb_math_Abs2(t_x:Number):Number{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<73>";
	if(t_x>=0.0){
		_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<73>";
		popErr();
		return t_x;
	}
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<74>";
	var t_:Number=-t_x;
	popErr();
	return t_;
}
class c_Enumerator6 extends Object{
	internal var m__list:c_List2=null;
	internal var m__curr:c_Node3=null;
	public function m_Enumerator_new(t_list:c_List2):c_Enumerator6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator6{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TSurface{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TSurface=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_Box extends Object{
	internal var m_a:c_Vector=null;
	internal var m_b:c_Vector=null;
	public function m_Box_new():c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<166>";
		m_a=(new c_Vector).m_Vector_new(999999999.000,999999999.000,999999999.000);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<167>";
		m_b=(new c_Vector).m_Vector_new(-999999999.000,-999999999.000,-999999999.000);
		popErr();
		return this;
	}
	public function m_Box_new2(t_q:c_Vector):c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<171>";
		m_a=t_q.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<172>";
		m_b=t_q.p_Copy();
		popErr();
		return this;
	}
	public function m_Box_new3(t_aa:c_Vector,t_bb:c_Vector):c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<176>";
		m_a=t_aa.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<177>";
		m_b=t_bb.p_Copy();
		popErr();
		return this;
	}
	public function m_Box_new4(t_aa:c_Vector,t_bb:c_Vector,t_cc:c_Vector):c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<181>";
		m_a=t_aa.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<182>";
		m_b=t_aa.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<183>";
		var t_q:c_Vector=t_bb;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<184>";
		if(dbg_object(t_q).m_x<dbg_object(m_a).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<184>";
			dbg_object(m_a).m_x=dbg_object(t_q).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<185>";
		if(dbg_object(t_q).m_y<dbg_object(m_a).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<185>";
			dbg_object(m_a).m_y=dbg_object(t_q).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<186>";
		if(dbg_object(t_q).m_z<dbg_object(m_a).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<186>";
			dbg_object(m_a).m_z=dbg_object(t_q).m_z;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<187>";
		if(dbg_object(t_q).m_x>dbg_object(m_b).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<187>";
			dbg_object(m_b).m_x=dbg_object(t_q).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<188>";
		if(dbg_object(t_q).m_y>dbg_object(m_b).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<188>";
			dbg_object(m_b).m_y=dbg_object(t_q).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<189>";
		if(dbg_object(t_q).m_z>dbg_object(m_b).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<189>";
			dbg_object(m_b).m_z=dbg_object(t_q).m_z;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<190>";
		t_q=t_cc;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<191>";
		if(dbg_object(t_q).m_x<dbg_object(m_a).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<191>";
			dbg_object(m_a).m_x=dbg_object(t_q).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<192>";
		if(dbg_object(t_q).m_y<dbg_object(m_a).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<192>";
			dbg_object(m_a).m_y=dbg_object(t_q).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<193>";
		if(dbg_object(t_q).m_z<dbg_object(m_a).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<193>";
			dbg_object(m_a).m_z=dbg_object(t_q).m_z;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<194>";
		if(dbg_object(t_q).m_x>dbg_object(m_b).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<194>";
			dbg_object(m_b).m_x=dbg_object(t_q).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<195>";
		if(dbg_object(t_q).m_y>dbg_object(m_b).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<195>";
			dbg_object(m_b).m_y=dbg_object(t_q).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<196>";
		if(dbg_object(t_q).m_z>dbg_object(m_b).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<196>";
			dbg_object(m_b).m_z=dbg_object(t_q).m_z;
		}
		popErr();
		return this;
	}
	public function p_Update10(t_q:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<242>";
		if(dbg_object(t_q).m_x<dbg_object(m_a).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<242>";
			dbg_object(m_a).m_x=dbg_object(t_q).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<243>";
		if(dbg_object(t_q).m_y<dbg_object(m_a).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<243>";
			dbg_object(m_a).m_y=dbg_object(t_q).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<244>";
		if(dbg_object(t_q).m_z<dbg_object(m_a).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<244>";
			dbg_object(m_a).m_z=dbg_object(t_q).m_z;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<245>";
		if(dbg_object(t_q).m_x>dbg_object(m_b).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<245>";
			dbg_object(m_b).m_x=dbg_object(t_q).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<246>";
		if(dbg_object(t_q).m_y>dbg_object(m_b).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<246>";
			dbg_object(m_b).m_y=dbg_object(t_q).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<247>";
		if(dbg_object(t_q).m_z>dbg_object(m_b).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<247>";
			dbg_object(m_b).m_z=dbg_object(t_q).m_z;
		}
		popErr();
		return 0;
	}
	public function p_Update11(t_q:c_Box):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<251>";
		if(dbg_object(dbg_object(t_q).m_a).m_x<dbg_object(m_a).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<251>";
			dbg_object(m_a).m_x=dbg_object(dbg_object(t_q).m_a).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<252>";
		if(dbg_object(dbg_object(t_q).m_a).m_y<dbg_object(m_a).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<252>";
			dbg_object(m_a).m_y=dbg_object(dbg_object(t_q).m_a).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<253>";
		if(dbg_object(dbg_object(t_q).m_a).m_z<dbg_object(m_a).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<253>";
			dbg_object(m_a).m_z=dbg_object(dbg_object(t_q).m_a).m_z;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<254>";
		if(dbg_object(dbg_object(t_q).m_b).m_x>dbg_object(m_b).m_x){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<254>";
			dbg_object(m_b).m_x=dbg_object(dbg_object(t_q).m_b).m_x;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<255>";
		if(dbg_object(dbg_object(t_q).m_b).m_y>dbg_object(m_b).m_y){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<255>";
			dbg_object(m_b).m_y=dbg_object(dbg_object(t_q).m_b).m_y;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<256>";
		if(dbg_object(dbg_object(t_q).m_b).m_z>dbg_object(m_b).m_z){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<256>";
			dbg_object(m_b).m_z=dbg_object(dbg_object(t_q).m_b).m_z;
		}
		popErr();
		return 0;
	}
	public function p_Update4(t_l:c_Line):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<261>";
		m_a.p_Overwrite3(dbg_object(t_l).m_o);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<262>";
		m_b.p_Overwrite3(dbg_object(t_l).m_o);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<263>";
		this.p_Update10(dbg_object(t_l).m_o.p_Add(dbg_object(t_l).m_d));
		popErr();
		return 0;
	}
	public function m_Box_new5(t_l:c_Line):c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<200>";
		m_a=dbg_object(t_l).m_o.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<201>";
		m_b=dbg_object(t_l).m_o.p_Copy();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<202>";
		this.p_Update10(dbg_object(t_l).m_o.p_Add(dbg_object(t_l).m_d));
		popErr();
		return this;
	}
	public function p_Corner(t_n:int):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<231>";
		var t_q:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<231>";
		var t_w:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<231>";
		var t_e:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<232>";
		if((t_n&1)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<232>";
			t_q=m_b;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<232>";
			t_q=m_a;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<234>";
		if((t_n&2)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<234>";
			t_w=m_b;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<234>";
			t_w=m_a;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<236>";
		if((t_n&4)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<236>";
			t_e=m_b;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<236>";
			t_e=m_a;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<238>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(dbg_object(t_q).m_x,dbg_object(t_w).m_y,dbg_object(t_e).m_z);
		popErr();
		return t_;
	}
	public function p_Clear():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<210>";
		dbg_object(m_a).m_x=999999999.000;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<211>";
		dbg_object(m_a).m_y=999999999.000;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<212>";
		dbg_object(m_a).m_z=999999999.000;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<213>";
		dbg_object(m_b).m_x=-999999999.000;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<214>";
		dbg_object(m_b).m_y=-999999999.000;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<215>";
		dbg_object(m_b).m_z=-999999999.000;
		popErr();
		return 0;
	}
	public function p_Scale2(t_n:c_Vector):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<305>";
		dbg_object(m_a).m_x*=dbg_object(t_n).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<305>";
		dbg_object(m_a).m_y*=dbg_object(t_n).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<305>";
		dbg_object(m_a).m_z*=dbg_object(t_n).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<305>";
		dbg_object(m_b).m_x*=dbg_object(t_n).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<305>";
		dbg_object(m_b).m_y*=dbg_object(t_n).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<305>";
		dbg_object(m_b).m_z*=dbg_object(t_n).m_z;
		popErr();
		return 0;
	}
	public function p_Width():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<309>";
		var t_:Number=dbg_object(m_b).m_x-dbg_object(m_a).m_x;
		popErr();
		return t_;
	}
	public function p_Height():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<313>";
		var t_:Number=dbg_object(m_b).m_y-dbg_object(m_a).m_y;
		popErr();
		return t_;
	}
	public function p_Depth():Number{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<317>";
		var t_:Number=dbg_object(m_b).m_z-dbg_object(m_a).m_z;
		popErr();
		return t_;
	}
	public function p_Overlaps(t_q:c_Box):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<286>";
		var t_:Boolean=(dbg_object(m_b).m_x<dbg_object(dbg_object(t_q).m_b).m_x && dbg_object(m_b).m_x>=dbg_object(m_a).m_x && dbg_object(m_b).m_x>=dbg_object(dbg_object(t_q).m_a).m_x || dbg_object(m_b).m_x>dbg_object(dbg_object(t_q).m_b).m_x && dbg_object(dbg_object(t_q).m_b).m_x>=dbg_object(m_a).m_x && dbg_object(dbg_object(t_q).m_b).m_x>=dbg_object(dbg_object(t_q).m_a).m_x) && (dbg_object(m_b).m_y<dbg_object(dbg_object(t_q).m_b).m_y && dbg_object(m_b).m_y>=dbg_object(m_a).m_y && dbg_object(m_b).m_y>=dbg_object(dbg_object(t_q).m_a).m_y || dbg_object(m_b).m_y>dbg_object(dbg_object(t_q).m_b).m_y && dbg_object(dbg_object(t_q).m_b).m_y>=dbg_object(m_a).m_y && dbg_object(dbg_object(t_q).m_b).m_y>=dbg_object(dbg_object(t_q).m_a).m_y) && (dbg_object(m_b).m_z<dbg_object(dbg_object(t_q).m_b).m_z && dbg_object(m_b).m_z>=dbg_object(m_a).m_z && dbg_object(m_b).m_z>=dbg_object(dbg_object(t_q).m_a).m_z || dbg_object(m_b).m_z>dbg_object(dbg_object(t_q).m_b).m_z && dbg_object(dbg_object(t_q).m_b).m_z>=dbg_object(m_a).m_z && dbg_object(dbg_object(t_q).m_b).m_z>=dbg_object(dbg_object(t_q).m_a).m_z);
		popErr();
		return t_;
	}
	public function p_Overlaps2(t_q:c_Vector):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<292>";
		var t_:Boolean=dbg_object(t_q).m_x<dbg_object(m_b).m_x && dbg_object(t_q).m_x>=dbg_object(m_a).m_x && (dbg_object(t_q).m_y<dbg_object(m_b).m_y && dbg_object(t_q).m_y>=dbg_object(m_a).m_y) && (dbg_object(t_q).m_z<dbg_object(m_b).m_z && dbg_object(t_q).m_z>=dbg_object(m_a).m_z);
		popErr();
		return t_;
	}
	public function p_Center():c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<227>";
		var t_:c_Vector=(new c_Vector).m_Vector_new((dbg_object(m_a).m_x+dbg_object(m_b).m_x)*0.5,(dbg_object(m_a).m_y+dbg_object(m_b).m_y)*0.5,(dbg_object(m_a).m_z+dbg_object(m_b).m_z)*0.5);
		popErr();
		return t_;
	}
	public function p_Copy():c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/geom.monkey<206>";
		var t_:c_Box=(new c_Box).m_Box_new3(dbg_object(this).m_a,dbg_object(this).m_b);
		popErr();
		return t_;
	}
}
class c_List10 extends Object{
	public function m_List_new():c_List10{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node12=((new c_HeadNode10).m_HeadNode_new());
	public function p_AddLast10(t_data:c_TCollisionPair):c_Node12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node12=(new c_Node12).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TCollisionPair=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast10(t_t);
		}
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_Enumerator7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator7=(new c_Enumerator7).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_Node12 extends Object{
	internal var m__succ:c_Node12=null;
	internal var m__pred:c_Node12=null;
	internal var m__data:c_TCollisionPair=null;
	public function m_Node_new(t_succ:c_Node12,t_pred:c_Node12,t_data:c_TCollisionPair):c_Node12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode10 extends c_Node12{
	public function m_HeadNode_new():c_HeadNode10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_Enumerator7 extends Object{
	internal var m__list:c_List10=null;
	internal var m__curr:c_Node12=null;
	public function m_Enumerator_new(t_list:c_List10):c_Enumerator7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator7{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TCollisionPair{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TCollisionPair=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_Vec3 extends c_Vector{
	public static function m_Add(t_a:c_Vector,t_b:c_Vector,t_out:c_Vector):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<14>";
		dbg_object(t_out).m_x=dbg_object(t_a).m_x+dbg_object(t_b).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<14>";
		dbg_object(t_out).m_y=dbg_object(t_a).m_y+dbg_object(t_b).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<14>";
		dbg_object(t_out).m_z=dbg_object(t_a).m_z+dbg_object(t_b).m_z;
		popErr();
	}
	public static function m_Multiply(t_a:c_Vector,t_b:c_Vector,t_out:c_Vector):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<18>";
		dbg_object(t_out).m_x=dbg_object(t_a).m_x*dbg_object(t_b).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<18>";
		dbg_object(t_out).m_y=dbg_object(t_a).m_y*dbg_object(t_b).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<18>";
		dbg_object(t_out).m_z=dbg_object(t_a).m_z*dbg_object(t_b).m_z;
		popErr();
	}
	public static function m_Multiply2(t_a:c_Vector,t_b:Number,t_out:c_Vector):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<22>";
		dbg_object(t_out).m_x=dbg_object(t_a).m_x*t_b;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<22>";
		dbg_object(t_out).m_y=dbg_object(t_a).m_y*t_b;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<22>";
		dbg_object(t_out).m_z=dbg_object(t_a).m_z*t_b;
		popErr();
	}
	internal static var m_temp:c_Vector;
	public static function m_Multiply3(t_a:c_Vector,t_b:c_Matrix,t_out:c_Vector):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<27>";
		dbg_object(m_temp).m_x=dbg_array(dbg_array(dbg_object(t_b).m_grid,0)[dbg_index],0)[dbg_index]*dbg_object(t_a).m_x+dbg_array(dbg_array(dbg_object(t_b).m_grid,1)[dbg_index],0)[dbg_index]*dbg_object(t_a).m_y+dbg_array(dbg_array(dbg_object(t_b).m_grid,2)[dbg_index],0)[dbg_index]*dbg_object(t_a).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<28>";
		dbg_object(m_temp).m_y=dbg_array(dbg_array(dbg_object(t_b).m_grid,0)[dbg_index],1)[dbg_index]*dbg_object(t_a).m_x+dbg_array(dbg_array(dbg_object(t_b).m_grid,1)[dbg_index],1)[dbg_index]*dbg_object(t_a).m_y+dbg_array(dbg_array(dbg_object(t_b).m_grid,2)[dbg_index],1)[dbg_index]*dbg_object(t_a).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<29>";
		dbg_object(m_temp).m_z=dbg_array(dbg_array(dbg_object(t_b).m_grid,0)[dbg_index],2)[dbg_index]*dbg_object(t_a).m_x+dbg_array(dbg_array(dbg_object(t_b).m_grid,1)[dbg_index],2)[dbg_index]*dbg_object(t_a).m_y+dbg_array(dbg_array(dbg_object(t_b).m_grid,2)[dbg_index],2)[dbg_index]*dbg_object(t_a).m_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<30>";
		dbg_object(t_out).m_x=dbg_object(m_temp).m_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<31>";
		dbg_object(t_out).m_y=dbg_object(m_temp).m_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/vec3.monkey<32>";
		dbg_object(t_out).m_z=dbg_object(m_temp).m_z;
		popErr();
	}
}
class c_MeshCollider extends Object{
	internal var m_tri_count:int=0;
	internal var m_vert_count:int=0;
	internal var m_tris:Array=[];
	internal var m_tri_surface:Array=[];
	internal var m_tri_number:Array=[];
	internal var m_tri_vix:Array=[];
	internal var m_tri_verts:Array=[];
	internal var m_tri_centres:Array=[];
	public function m_MeshCollider_new(t_no_verts:int,t_no_tris:int):c_MeshCollider{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<500>";
		m_tri_count=t_no_tris;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<501>";
		m_vert_count=t_no_verts;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<502>";
		m_tris=new_number_array(t_no_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<503>";
		m_tri_surface=new_number_array(t_no_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<504>";
		m_tri_number=new_number_array(t_no_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<505>";
		m_tri_vix=new_number_array(t_no_tris*3);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<506>";
		m_tri_verts=new_object_array(t_no_verts);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<507>";
		m_tri_centres=new_object_array(t_no_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<509>";
		for(var t_i:int=0;t_i<=t_no_verts-1;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<510>";
			dbg_array(m_tri_verts,t_i)[dbg_index]=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<513>";
		for(var t_i2:int=0;t_i2<=t_no_tris-1;t_i2=t_i2+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<514>";
			dbg_array(m_tri_centres,t_i2)[dbg_index]=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		}
		popErr();
		return this;
	}
	public function m_MeshCollider_new2():c_MeshCollider{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<456>";
		popErr();
		return this;
	}
	public function p_CreateNodeBox(t_tris:Array):c_Box{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<526>";
		if(t_tris.length<1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<526>";
			var t_:c_Box=(new c_Box).m_Box_new();
			popErr();
			return t_;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<529>";
		var t_box:c_Box=(new c_Box).m_Box_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<531>";
		for(var t_k:int=0;t_k<=t_tris.length-1;t_k=t_k+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<533>";
			if(dbg_array(t_tris,t_k)[dbg_index]!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<534>";
				var t_ti:int=dbg_array(t_tris,t_k)[dbg_index]*3;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<535>";
				t_box.p_Update10(dbg_array(m_tri_verts,dbg_array(m_tri_vix,t_ti+0)[dbg_index])[dbg_index]);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<536>";
				t_box.p_Update10(dbg_array(m_tri_verts,dbg_array(m_tri_vix,t_ti+1)[dbg_index])[dbg_index]);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<537>";
				t_box.p_Update10(dbg_array(m_tri_verts,dbg_array(m_tri_vix,t_ti+2)[dbg_index])[dbg_index]);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<542>";
		popErr();
		return t_box;
	}
	internal var m_leaf_list:c_List11=(new c_List11).m_List_new();
	public function p_CreateLeaf(t_tris:Array):c_Node13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<547>";
		var t_c:c_Node13=(new c_Node13).m_Node_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<548>";
		dbg_object(t_c).m_box=this.p_CreateNodeBox(t_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<549>";
		dbg_object(t_c).m_triangles=t_tris;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<550>";
		m_leaf_list.p_AddLast11(t_c);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<551>";
		dbg_object(t_c).m_level=9999;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<553>";
		popErr();
		return t_c;
	}
	public function p_CreateNode(t_tris:Array,t_level:int,t_max_tris:int):c_Node13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<562>";
		if(t_tris.length<=t_max_tris){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<562>";
			var t_:c_Node13=this.p_CreateLeaf(t_tris);
			popErr();
			return t_;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<564>";
		var t_c:c_Node13=(new c_Node13).m_Node_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<565>";
		dbg_object(t_c).m_box=this.p_CreateNodeBox(t_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<566>";
		dbg_object(t_c).m_level=t_level;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<569>";
		var t_max:Number=dbg_object(t_c).m_box.p_Width();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<570>";
		var t_axis:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<571>";
		if(dbg_object(t_c).m_box.p_Height()>t_max){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<571>";
			t_max=dbg_object(t_c).m_box.p_Height();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<571>";
			t_axis=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<572>";
		if(dbg_object(t_c).m_box.p_Depth()>t_max){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<572>";
			t_max=dbg_object(t_c).m_box.p_Depth();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<572>";
			t_axis=2;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<578>";
		var t_k:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<578>";
		var t_tri:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<580>";
		var t_axis_map:c_PairList=(new c_PairList).m_PairList_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<581>";
		var t_num:int=t_tris.length;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<583>";
		var t_real_total:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<585>";
		for(t_k=0;t_k<=t_num-1;t_k=t_k+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<587>";
			t_tri=dbg_array(t_tris,t_k)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<588>";
			if(t_tri==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<588>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<590>";
			var t_ap:c_AxisPair=(new c_AxisPair).m_AxisPair_new();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<591>";
			if(t_axis==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<592>";
				dbg_object(t_ap).m_key=dbg_object(dbg_array(m_tri_centres,t_tri)[dbg_index]).m_x;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<592>";
				dbg_object(t_ap).m_value=t_tri;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<593>";
				if(t_axis==1){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<594>";
					dbg_object(t_ap).m_key=dbg_object(dbg_array(m_tri_centres,t_tri)[dbg_index]).m_y;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<594>";
					dbg_object(t_ap).m_value=t_tri;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<596>";
					dbg_object(t_ap).m_key=dbg_object(dbg_array(m_tri_centres,t_tri)[dbg_index]).m_z;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<596>";
					dbg_object(t_ap).m_value=t_tri;
				}
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<598>";
			t_axis_map.p_AddLast12(t_ap);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<600>";
			t_real_total+=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<604>";
		t_axis_map.p_Sort(1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<607>";
		var t_index:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<608>";
		var t_num_left:int=(((t_real_total)*0.5)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<609>";
		var t_num_right:int=t_real_total-t_num_left;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<610>";
		var t_newtris:Array=new_number_array(t_num_left+1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<611>";
		var t_newtris2:Array=new_number_array(t_num_right+1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<612>";
		var t_leftset:int=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<612>";
		var t_lastval:int=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<614>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<614>";
		var t_2:c_Enumerator8=t_axis_map.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<614>";
		while(t_2.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<614>";
			var t_ap2:c_AxisPair=t_2.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<618>";
			if(t_index<=t_num_left){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<619>";
				dbg_array(t_newtris,t_index)[dbg_index]=dbg_object(t_ap2).m_value;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<620>";
				t_lastval=dbg_object(t_ap2).m_value;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<622>";
				dbg_array(t_newtris2,t_index-t_num_left-1)[dbg_index]=dbg_object(t_ap2).m_value;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<623>";
				t_lastval=dbg_object(t_ap2).m_value;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<626>";
			t_index+=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<629>";
		dbg_object(t_c).m_left=this.p_CreateNode(t_newtris,t_level+1,t_max_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<630>";
		dbg_object(t_c).m_right=this.p_CreateNode(t_newtris2,t_level+1,t_max_tris);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<632>";
		popErr();
		return t_c;
	}
	internal var m_tree:c_Node13=null;
	internal static var m_ray_line:c_Line;
	internal var m_r_invx:Number=.0;
	internal var m_r_invy:Number=.0;
	internal var m_r_invz:Number=.0;
	internal var m_r_sign:Array=new_number_array(3);
	public function p_RayBoxSetup(t_line2:c_Line):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<988>";
		m_ray_line=t_line2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<991>";
		var t_ln:Number=1.0/t_line2.p_Length();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<992>";
		var t_dir:c_Vector=(new c_Vector).m_Vector_new((dbg_object(dbg_object(t_line2).m_o).m_x-dbg_object(dbg_object(t_line2).m_d).m_x)*t_ln,(dbg_object(dbg_object(t_line2).m_o).m_y-dbg_object(dbg_object(t_line2).m_d).m_y)*t_ln,(dbg_object(dbg_object(t_line2).m_o).m_z-dbg_object(dbg_object(t_line2).m_d).m_z)*t_ln);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<993>";
		if(t_ln!=1.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<993>";
			m_r_invx=1.0/dbg_object(t_dir).m_x;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<993>";
			m_r_invy=1.0/dbg_object(t_dir).m_y;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<993>";
			m_r_invz=1.0/dbg_object(t_dir).m_z;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<996>";
		dbg_array(m_r_sign,0)[dbg_index]=((m_r_invx<0.0)?1:0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<997>";
		dbg_array(m_r_sign,1)[dbg_index]=((m_r_invy<0.0)?1:0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<998>";
		dbg_array(m_r_sign,2)[dbg_index]=((m_r_invz<0.0)?1:0);
		popErr();
		return 0;
	}
	internal var m_tri_node_stack:c_Stack4=(new c_Stack4).m_Stack_new();
	public function p_ClearTriNodeStack():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<521>";
		m_tri_node_stack.p_Clear();
		popErr();
	}
	public function p_RayBoxTest(t_li:c_Line,t_box:c_Box):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1006>";
		var t_tmin:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1006>";
		var t_tmax:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1006>";
		var t_tymin:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1006>";
		var t_tymax:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1006>";
		var t_tzmin:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1006>";
		var t_tzmax:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1007>";
		var t_bounds:Array=new_object_array(2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1009>";
		dbg_array(t_bounds,0)[dbg_index]=dbg_object(t_box).m_a;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1010>";
		dbg_array(t_bounds,1)[dbg_index]=dbg_object(t_box).m_b;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1012>";
		t_tmin=(dbg_object(dbg_array(t_bounds,dbg_array(m_r_sign,0)[dbg_index])[dbg_index]).m_x-dbg_object(dbg_object(t_li).m_o).m_x)*m_r_invx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1013>";
		t_tmax=(dbg_object(dbg_array(t_bounds,1-dbg_array(m_r_sign,0)[dbg_index])[dbg_index]).m_x-dbg_object(dbg_object(t_li).m_o).m_x)*m_r_invx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1014>";
		t_tymin=(dbg_object(dbg_array(t_bounds,dbg_array(m_r_sign,1)[dbg_index])[dbg_index]).m_y-dbg_object(dbg_object(t_li).m_o).m_y)*m_r_invy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1015>";
		t_tymax=(dbg_object(dbg_array(t_bounds,1-dbg_array(m_r_sign,1)[dbg_index])[dbg_index]).m_y-dbg_object(dbg_object(t_li).m_o).m_y)*m_r_invy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1017>";
		if(t_tmin>t_tymax || t_tymin>t_tmax){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1017>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1018>";
		if(t_tymin>t_tmin){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1018>";
			t_tmin=t_tymin;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1019>";
		if(t_tymax<t_tmax){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1019>";
			t_tmax=t_tymax;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1021>";
		t_tzmin=(dbg_object(dbg_array(t_bounds,dbg_array(m_r_sign,2)[dbg_index])[dbg_index]).m_z-dbg_object(dbg_object(t_li).m_o).m_z)*m_r_invz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1022>";
		t_tzmax=(dbg_object(dbg_array(t_bounds,1-dbg_array(m_r_sign,2)[dbg_index])[dbg_index]).m_z-dbg_object(dbg_object(t_li).m_o).m_z)*m_r_invz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1024>";
		if(t_tmin>t_tzmax || t_tzmin>t_tmax){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1024>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<1030>";
		popErr();
		return 1;
	}
	public function p_CollideNodeAABB(t_line_box:c_Box,t_radius:c_Vector,t_curr_coll:c_CollisionObject,t_node:c_Node13,t_check_only:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<762>";
		if(t_node==null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<762>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<764>";
		if(t_node==m_tree && t_check_only==false){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<766>";
			this.p_ClearTriNodeStack();
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<771>";
		if(!t_line_box.p_Overlaps(dbg_object(t_node).m_box)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<771>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<774>";
		if(dbg_object(t_radius).m_x==0.0 && !((this.p_RayBoxTest(m_ray_line,dbg_object(t_node).m_box))!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<774>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<776>";
		var t_hit:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<778>";
		if(dbg_object(t_node).m_triangles.length<1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<780>";
			if((dbg_object(t_node).m_left)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<780>";
				t_hit=t_hit|this.p_CollideNodeAABB(t_line_box,t_radius,t_curr_coll,dbg_object(t_node).m_left,false);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<781>";
			if((dbg_object(t_node).m_right)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<781>";
				t_hit=t_hit|this.p_CollideNodeAABB(t_line_box,t_radius,t_curr_coll,dbg_object(t_node).m_right,false);
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<784>";
			t_hit=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<785>";
			if(t_check_only==false){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<785>";
				m_tri_node_stack.p_Push10(t_node);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<791>";
		popErr();
		return t_hit;
	}
	public function p_TriNodeCollide(t_line_box:c_Box,t_line:c_Line,t_s_radius:c_Vector,t_coll_obj:c_CollisionObject,t_scalef:c_Vector,t_bypass_test:Boolean):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<798>";
		var t_hit:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<799>";
		var t_tritest:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<800>";
		var t_str:String="";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<801>";
		var t_v0:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<801>";
		var t_v1:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<801>";
		var t_v2:c_Vector=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<801>";
		var t_tri_box:c_Box=(new c_Box).m_Box_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<805>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<805>";
		var t_:c_Enumerator9=m_tri_node_stack.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<805>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<805>";
			var t_node:c_Node13=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<808>";
			for(var t_k:int=0;t_k<=dbg_object(t_node).m_triangles.length-1;t_k=t_k+1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<810>";
				var t_miss:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<811>";
				var t_tri:int=dbg_array(dbg_object(t_node).m_triangles,t_k)[dbg_index]*3;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<813>";
				t_v0=dbg_array(m_tri_verts,dbg_array(m_tri_vix,t_tri+0)[dbg_index])[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<814>";
				t_v1=dbg_array(m_tri_verts,dbg_array(m_tri_vix,t_tri+1)[dbg_index])[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<815>";
				t_v2=dbg_array(m_tri_verts,dbg_array(m_tri_vix,t_tri+2)[dbg_index])[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<821>";
				dbg_object(t_tri_box).m_a.p_Overwrite3(t_v0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<822>";
				dbg_object(t_tri_box).m_b.p_Overwrite3(t_v0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<823>";
				t_tri_box.p_Update10(t_v1);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<824>";
				t_tri_box.p_Update10(t_v2);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<826>";
				if(t_tri_box.p_Overlaps(t_line_box)){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<828>";
					if(t_bypass_test){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<829>";
						var t_norm:c_Vector=null;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<830>";
						var t_cen:c_Vector=t_tri_box.p_Center();
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<831>";
						var t_nx:Number=bb_math_Abs2(dbg_object(dbg_object(t_line).m_d).m_x);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<832>";
						var t_ny:Number=bb_math_Abs2(dbg_object(dbg_object(t_line).m_d).m_y);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<833>";
						var t_nz:Number=bb_math_Abs2(dbg_object(dbg_object(t_line).m_d).m_z);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<835>";
						if(t_nx>t_ny && t_nx>t_nz){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<836>";
							t_norm=(new c_Vector).m_Vector_new(-bb_math_Sgn2(dbg_object(dbg_object(t_line).m_d).m_x),0.0,0.0);
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<838>";
							if(t_ny>t_nx && t_ny>t_nz){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<839>";
								t_norm=(new c_Vector).m_Vector_new(0.0,-bb_math_Sgn2(dbg_object(dbg_object(t_line).m_d).m_y),0.0);
							}else{
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<841>";
								if(t_nz>t_nx && t_nz>t_ny){
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<842>";
									t_norm=(new c_Vector).m_Vector_new(0.0,0.0,-bb_math_Sgn2(dbg_object(dbg_object(t_line).m_d).m_z));
								}else{
									_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<845>";
									t_norm=(new c_Vector).m_Vector_new(-bb_math_Sgn2(dbg_object(dbg_object(t_line).m_d).m_x),-bb_math_Sgn2(dbg_object(dbg_object(t_line).m_d).m_y),-bb_math_Sgn2(dbg_object(dbg_object(t_line).m_d).m_z));
								}
							}
						}
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<849>";
						dbg_object(t_coll_obj).m_surface=dbg_array(m_tri_surface,dbg_array(dbg_object(t_node).m_triangles,t_k)[dbg_index])[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<850>";
						dbg_object(t_coll_obj).m_index=dbg_array(m_tri_number,dbg_array(dbg_object(t_node).m_triangles,t_k)[dbg_index])[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<851>";
						dbg_object(t_coll_obj).m_normal=t_norm;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<852>";
						dbg_object(t_coll_obj).m_col_coords=dbg_object(t_line).m_o.p_Add(dbg_object(t_line).m_d);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<853>";
						dbg_object(t_coll_obj).m_time=0.5;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<855>";
						popErr();
						return 1;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<860>";
					if(dbg_object(t_s_radius).m_x>0.0001){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<867>";
						if(!((t_coll_obj.p_SphereTriangle(t_line,t_s_radius,t_v0.p_Multiply2(t_scalef),t_v1.p_Multiply2(t_scalef),t_v2.p_Multiply2(t_scalef)))!=0)){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<867>";
							t_miss=1;
						}
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<873>";
						if(!((t_coll_obj.p_RayTriangle(t_line,t_v0.p_Multiply2(t_scalef),t_v1.p_Multiply2(t_scalef),t_v2.p_Multiply2(t_scalef)))!=0)){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<873>";
							t_miss=1;
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<881>";
					if(!((t_miss)!=0)){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<882>";
						dbg_object(t_coll_obj).m_surface=dbg_array(m_tri_surface,dbg_array(dbg_object(t_node).m_triangles,t_k)[dbg_index])[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<883>";
						dbg_object(t_coll_obj).m_index=dbg_array(m_tri_number,dbg_array(dbg_object(t_node).m_triangles,t_k)[dbg_index])[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<887>";
						t_hit+=1;
					}
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<898>";
		if(t_str.length>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<898>";
			print(t_str+"\n");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<901>";
		popErr();
		return t_hit;
	}
}
class c_Node13 extends Object{
	public function m_Node_new():c_Node13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<444>";
		popErr();
		return this;
	}
	internal var m_box:c_Box=null;
	internal var m_triangles:Array=[];
	internal var m_level:int=0;
	internal var m_left:c_Node13=null;
	internal var m_right:c_Node13=null;
	internal var m_name:String="";
}
class c_List11 extends Object{
	public function m_List_new():c_List11{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node14=((new c_HeadNode11).m_HeadNode_new());
	public function p_AddLast11(t_data:c_Node13):c_Node14{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node14=(new c_Node14).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_Node13=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast11(t_t);
		}
		popErr();
		return this;
	}
}
class c_Node14 extends Object{
	internal var m__succ:c_Node14=null;
	internal var m__pred:c_Node14=null;
	internal var m__data:c_Node13=null;
	public function m_Node_new(t_succ:c_Node14,t_pred:c_Node14,t_data:c_Node13):c_Node14{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node14{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode11 extends c_Node14{
	public function m_HeadNode_new():c_HeadNode11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_AxisPair extends Object{
	public function m_AxisPair_new():c_AxisPair{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<430>";
		popErr();
		return this;
	}
	internal var m_key:Number=.0;
	internal var m_value:int=0;
}
class c_List12 extends Object{
	public function m_List_new():c_List12{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node15=((new c_HeadNode12).m_HeadNode_new());
	public function p_AddLast12(t_data:c_AxisPair):c_Node15{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node15=(new c_Node15).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_AxisPair=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast12(t_t);
		}
		popErr();
		return this;
	}
	public function p_Compare4(t_lhs:c_AxisPair,t_rhs:c_AxisPair):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<32>";
		error("Unable to compare items");
		popErr();
		return 0;
	}
	public function p_Sort(t_ascending:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<194>";
		var t_ccsgn:int=-1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<195>";
		if((t_ascending)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<195>";
			t_ccsgn=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<196>";
		var t_insize:int=1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<198>";
		do{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<199>";
			var t_merges:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<200>";
			var t_tail:c_Node15=m__head;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<201>";
			var t_p:c_Node15=dbg_object(m__head).m__succ;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<203>";
			while(t_p!=m__head){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<204>";
				t_merges+=1;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<205>";
				var t_q:c_Node15=dbg_object(t_p).m__succ;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<205>";
				var t_qsize:int=t_insize;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<205>";
				var t_psize:int=1;
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<207>";
				while(t_psize<t_insize && t_q!=m__head){
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<208>";
					t_psize+=1;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<209>";
					t_q=dbg_object(t_q).m__succ;
				}
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<212>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<213>";
					var t_t:c_Node15=null;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<214>";
					if(((t_psize)!=0) && ((t_qsize)!=0) && t_q!=m__head){
						_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<215>";
						var t_cc:int=this.p_Compare4(dbg_object(t_p).m__data,dbg_object(t_q).m__data)*t_ccsgn;
						_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<216>";
						if(t_cc<=0){
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<217>";
							t_t=t_p;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<218>";
							t_p=dbg_object(t_p).m__succ;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<219>";
							t_psize-=1;
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<221>";
							t_t=t_q;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<222>";
							t_q=dbg_object(t_q).m__succ;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<223>";
							t_qsize-=1;
						}
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<225>";
						if((t_psize)!=0){
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<226>";
							t_t=t_p;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<227>";
							t_p=dbg_object(t_p).m__succ;
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<228>";
							t_psize-=1;
						}else{
							_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<229>";
							if(((t_qsize)!=0) && t_q!=m__head){
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<230>";
								t_t=t_q;
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<231>";
								t_q=dbg_object(t_q).m__succ;
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<232>";
								t_qsize-=1;
							}else{
								_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<234>";
								break;
							}
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<236>";
					dbg_object(t_t).m__pred=t_tail;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<237>";
					dbg_object(t_tail).m__succ=t_t;
					_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<238>";
					t_tail=t_t;
				}while(!(false));
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<240>";
				t_p=t_q;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<242>";
			dbg_object(t_tail).m__succ=m__head;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<243>";
			dbg_object(m__head).m__pred=t_tail;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<245>";
			if(t_merges<=1){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<245>";
				popErr();
				return 0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<247>";
			t_insize*=2;
		}while(!(false));
		return 0;
	}
	public function p_ObjectEnumerator():c_Enumerator8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator8=(new c_Enumerator8).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_PairList extends c_List12{
	public function m_PairList_new():c_PairList{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<436>";
		super.m_List_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<436>";
		popErr();
		return this;
	}
	public override function p_Compare4(t_lh:c_AxisPair,t_rh:c_AxisPair):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<438>";
		if(dbg_object(t_lh).m_key<dbg_object(t_rh).m_key){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<438>";
			popErr();
			return -1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tcoltree.monkey<439>";
		var t_:int=((dbg_object(t_lh).m_key>dbg_object(t_rh).m_key)?1:0);
		popErr();
		return t_;
	}
}
class c_Node15 extends Object{
	internal var m__succ:c_Node15=null;
	internal var m__pred:c_Node15=null;
	internal var m__data:c_AxisPair=null;
	public function m_Node_new(t_succ:c_Node15,t_pred:c_Node15,t_data:c_AxisPair):c_Node15{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node15{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode12 extends c_Node15{
	public function m_HeadNode_new():c_HeadNode12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_Enumerator8 extends Object{
	internal var m__list:c_List12=null;
	internal var m__curr:c_Node15=null;
	public function m_Enumerator_new(t_list:c_List12):c_Enumerator8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator8{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_AxisPair{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_AxisPair=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_Stack4 extends Object{
	public function m_Stack_new():c_Stack4{
		pushErr();
		popErr();
		return this;
	}
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_Stack_new2(t_data:Array):c_Stack4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<13>";
		dbg_object(this).m_data=t_data.slice(0);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<14>";
		dbg_object(this).m_length=t_data.length;
		popErr();
		return this;
	}
	internal static var m_NIL:c_Node13;
	public function p_Clear():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<34>";
		for(var t_i:int=0;t_i<m_length;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<35>";
			dbg_array(m_data,t_i)[dbg_index]=m_NIL;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<37>";
		m_length=0;
		popErr();
	}
	public function p_Push10(t_value:c_Node13):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<67>";
		if(m_length==m_data.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<68>";
			m_data=resize_object_array(m_data,m_length*2+10);
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<70>";
		dbg_array(m_data,m_length)[dbg_index]=t_value;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<71>";
		m_length+=1;
		popErr();
	}
	public function p_Push11(t_values:Array,t_offset:int,t_count:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<79>";
		for(var t_i:int=0;t_i<t_count;t_i=t_i+1){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<80>";
			this.p_Push10(dbg_array(t_values,t_offset+t_i)[dbg_index]);
		}
		popErr();
	}
	public function p_Push12(t_values:Array,t_offset:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<75>";
		this.p_Push11(t_values,t_offset,t_values.length-t_offset);
		popErr();
	}
	public function p_ObjectEnumerator():c_Enumerator9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<184>";
		var t_:c_Enumerator9=(new c_Enumerator9).m_Enumerator_new(this);
		popErr();
		return t_;
	}
	public function p_Length2(t_newlength:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<41>";
		if(t_newlength<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<42>";
			for(var t_i:int=t_newlength;t_i<m_length;t_i=t_i+1){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<43>";
				dbg_array(m_data,t_i)[dbg_index]=m_NIL;
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<45>";
			if(t_newlength>m_data.length){
				_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<46>";
				m_data=resize_object_array(m_data,bb_math_Max(m_length*2+10,t_newlength));
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<48>";
		m_length=t_newlength;
		popErr();
	}
	public function p_Length():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<52>";
		popErr();
		return m_length;
	}
}
class c_Enumerator9 extends Object{
	internal var m_stack:c_Stack4=null;
	public function m_Enumerator_new(t_stack:c_Stack4):c_Enumerator9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<255>";
		dbg_object(this).m_stack=t_stack;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator9{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<252>";
		popErr();
		return this;
	}
	internal var m_index:int=0;
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<259>";
		var t_:Boolean=m_index<m_stack.p_Length();
		popErr();
		return t_;
	}
	public function p_NextObject():c_Node13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<263>";
		m_index+=1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<264>";
		var t_:c_Node13=dbg_array(dbg_object(m_stack).m_data,m_index-1)[dbg_index];
		popErr();
		return t_;
	}
}
internal function bb_math_Sgn(t_x:int):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<41>";
	if(t_x<0){
		_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<41>";
		popErr();
		return -1;
	}
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<42>";
	var t_:int=((t_x>0)?1:0);
	popErr();
	return t_;
}
internal function bb_math_Sgn2(t_x:Number):Number{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<67>";
	if(t_x<0.0){
		_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<67>";
		popErr();
		return -1.0;
	}
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<68>";
	if(t_x>0.0){
		_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<68>";
		popErr();
		return 1.0;
	}
	_errInfo="C:/MonkeyXPro77f/modules/monkey/math.monkey<69>";
	popErr();
	return 0.0;
}
class c_TAnimation extends Object{
	public static function m_VertexDeform(t_ent:c_TMesh):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<314>";
		var t_ov:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<315>";
		var t_x:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<315>";
		var t_y:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<315>";
		var t_z:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<317>";
		var t_bone:c_TBone=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<318>";
		var t_weight:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<323>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<323>";
		var t_:c_Enumerator6=dbg_object(t_ent).m_surf_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<323>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<323>";
			var t_surf:c_TSurface=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<325>";
			var t_anim_surf:c_TSurface=t_ent.p_GetAnimSurface(t_surf);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<326>";
			if(!((t_anim_surf)!=null)){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<326>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<329>";
			dbg_object(t_anim_surf).m_reset_vbo=dbg_object(t_anim_surf).m_reset_vbo|1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<330>";
			dbg_object(t_anim_surf).m_vbo_dyn=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<332>";
			var t_vid:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<333>";
			var t_vid3:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<336>";
			for(var t_vid2:int=0;t_vid2<=dbg_object(t_anim_surf).m_no_verts-1;t_vid2=t_vid2+1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<338>";
				t_vid3=t_vid2*3;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<341>";
				var t_tweight:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<343>";
				if(dbg_array(dbg_object(t_anim_surf).m_vert_bone1_no,t_vid2)[dbg_index]!=0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<345>";
					t_bone=dbg_array(dbg_object(t_ent).m_bones,dbg_array(dbg_object(t_anim_surf).m_vert_bone1_no,t_vid2)[dbg_index]-1)[dbg_index];
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<346>";
					t_weight=dbg_array(dbg_object(t_anim_surf).m_vert_weight1,t_vid2)[dbg_index];
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<347>";
					t_tweight+=t_weight;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<349>";
					if(t_weight>0.0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<357>";
						dbg_object(t_surf).m_vert_data.p_GetVertCoords(t_ov,t_vid2);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<360>";
						t_x=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],0)[dbg_index])*t_weight;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<361>";
						t_y=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],1)[dbg_index])*t_weight;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<362>";
						t_z=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],2)[dbg_index])*t_weight;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<368>";
					if(dbg_array(dbg_object(t_anim_surf).m_vert_bone2_no,t_vid2)[dbg_index]!=0 && dbg_array(dbg_object(t_anim_surf).m_vert_weight2,t_vid2)[dbg_index]>0.0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<370>";
						t_bone=dbg_array(dbg_object(t_ent).m_bones,dbg_array(dbg_object(t_anim_surf).m_vert_bone2_no,t_vid2)[dbg_index]-1)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<371>";
						t_weight=dbg_array(dbg_object(t_anim_surf).m_vert_weight2,t_vid2)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<372>";
						t_tweight+=t_weight;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<375>";
						t_x+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],0)[dbg_index])*t_weight;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<376>";
						t_y+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],1)[dbg_index])*t_weight;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<377>";
						t_z+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],2)[dbg_index])*t_weight;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<381>";
						if(dbg_array(dbg_object(t_anim_surf).m_vert_bone3_no,t_vid2)[dbg_index]!=0 && dbg_array(dbg_object(t_anim_surf).m_vert_weight3,t_vid2)[dbg_index]>0.0){
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<383>";
							t_bone=dbg_array(dbg_object(t_ent).m_bones,dbg_array(dbg_object(t_anim_surf).m_vert_bone3_no,t_vid2)[dbg_index]-1)[dbg_index];
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<384>";
							t_weight=dbg_array(dbg_object(t_anim_surf).m_vert_weight3,t_vid2)[dbg_index];
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<385>";
							t_tweight+=t_weight;
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<388>";
							t_x+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],0)[dbg_index])*t_weight;
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<389>";
							t_y+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],1)[dbg_index])*t_weight;
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<390>";
							t_z+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],2)[dbg_index])*t_weight;
							_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<394>";
							if(dbg_array(dbg_object(t_anim_surf).m_vert_bone4_no,t_vid2)[dbg_index]!=0 && dbg_array(dbg_object(t_anim_surf).m_vert_weight4,t_vid2)[dbg_index]>0.0){
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<396>";
								t_bone=dbg_array(dbg_object(t_ent).m_bones,dbg_array(dbg_object(t_anim_surf).m_vert_bone4_no,t_vid2)[dbg_index]-1)[dbg_index];
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<397>";
								t_weight=dbg_array(dbg_object(t_anim_surf).m_vert_weight4,t_vid2)[dbg_index];
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<398>";
								t_tweight+=t_weight;
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<401>";
								t_x+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],0)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],0)[dbg_index])*t_weight;
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<402>";
								t_y+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],1)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],1)[dbg_index])*t_weight;
								_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<403>";
								t_z+=(dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,0)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_x+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,1)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_y+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,2)[dbg_index],2)[dbg_index]*dbg_object(t_ov).m_z+dbg_array(dbg_array(dbg_object(dbg_object(t_bone).m_tform_mat).m_grid,3)[dbg_index],2)[dbg_index])*t_weight;
							}
						}
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<424>";
					dbg_object(t_anim_surf).m_vert_data.p_PokeVertCoords(t_vid2,t_x,t_y,t_z);
				}
			}
		}
		popErr();
	}
	public static function m_AnimateMesh2(t_ent1:c_TEntity,t_framef:Number,t_start_frame:int,t_end_frame:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<99>";
		var t_temp_vec:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<101>";
		var t_mesh:c_TMesh=((t_ent1) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<103>";
		if(t_mesh!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<105>";
			if(dbg_object(t_mesh).m_anim==0 || t_mesh.p_Hidden()==true){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<105>";
				popErr();
				return 0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<107>";
			dbg_object(t_mesh).m_anim_render=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<111>";
			var t_quat:c_Quaternion=(new c_Quaternion).m_Quaternion_new();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<113>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<113>";
			var t_:Array=dbg_object(t_mesh).m_bones;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<113>";
			var t_2:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<113>";
			while(t_2<t_.length){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<113>";
				var t_bent:c_TBone=dbg_array(t_,t_2)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<113>";
				t_2=t_2+1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<115>";
				var t_i:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<116>";
				var t_ii:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<117>";
				var t_fd1:Number=t_framef;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<118>";
				var t_fd2:Number=1.0-t_fd1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<119>";
				var t_found:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<120>";
				var t_no_keys:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<121>";
				var t_w1:Number=.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<124>";
				var t_x1:Number=dbg_object(t_bent).m_kx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<125>";
				var t_y1:Number=dbg_object(t_bent).m_ky;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<126>";
				var t_z1:Number=dbg_object(t_bent).m_kz;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<128>";
				var t_w2:Number=.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<129>";
				var t_x2:Number=.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<130>";
				var t_y2:Number=.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<131>";
				var t_z2:Number=.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<133>";
				var t_flag:int=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<139>";
				t_i=t_start_frame-1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<140>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<141>";
					t_i=t_i+1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<142>";
					if(t_i>t_end_frame){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<142>";
						t_i=t_start_frame;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<142>";
						t_ii=t_ii+1;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<143>";
					t_flag=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_flags,t_i)[dbg_index]&1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<144>";
					if((t_flag)!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<145>";
						t_x2=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_px,t_i)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<146>";
						t_y2=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_py,t_i)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<147>";
						t_z2=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_pz,t_i)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<149>";
						t_found=1;
					}
				}while(!(t_found==1 || t_ii>=2));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<152>";
				if(t_found==0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<152>";
					t_no_keys=1;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<153>";
				t_found=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<154>";
				t_ii=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<156>";
				var t_px3:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<157>";
				var t_py3:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<158>";
				var t_pz3:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<159>";
				if(t_no_keys==1){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<160>";
					t_px3=dbg_object(t_bent).m_n_px;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<161>";
					t_py3=dbg_object(t_bent).m_n_py;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<162>";
					t_pz3=dbg_object(t_bent).m_n_pz;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<164>";
					if(t_fd1+t_fd2==0.0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<167>";
						t_px3=t_x1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<168>";
						t_py3=t_y1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<169>";
						t_pz3=t_z1;
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<171>";
						var t_fd_inv:Number=1.0/(t_fd1+t_fd2);
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<172>";
						t_px3=(t_x2-t_x1)*t_fd_inv*t_fd1+t_x1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<173>";
						t_py3=(t_y2-t_y1)*t_fd_inv*t_fd1+t_y1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<174>";
						t_pz3=(t_z2-t_z1)*t_fd_inv*t_fd1+t_z1;
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<177>";
				t_no_keys=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<180>";
				t_w1=dbg_object(t_bent).m_kqw;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<181>";
				t_x1=dbg_object(t_bent).m_kqx;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<182>";
				t_y1=dbg_object(t_bent).m_kqy;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<183>";
				t_z1=dbg_object(t_bent).m_kqz;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<189>";
				t_i=t_start_frame-1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<190>";
				do{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<191>";
					t_i=t_i+1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<192>";
					if(t_i>t_end_frame){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<192>";
						t_i=t_start_frame;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<192>";
						t_ii=t_ii+1;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<193>";
					t_flag=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_flags,t_i)[dbg_index]&4;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<194>";
					if((t_flag)!=0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<195>";
						t_w2=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_qw,t_i)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<196>";
						t_x2=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_qx,t_i)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<197>";
						t_y2=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_qy,t_i)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<198>";
						t_z2=dbg_array(dbg_object(dbg_object(t_bent).m_keys).m_qz,t_i)[dbg_index];
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<200>";
						t_found=1;
					}
				}while(!(t_found==1 || t_ii>=2));
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<203>";
				if(t_found==0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<203>";
					t_no_keys=1;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<204>";
				t_found=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<205>";
				t_ii=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<209>";
				var t_w3:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<210>";
				var t_x3:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<211>";
				var t_y3:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<212>";
				var t_z3:Number=0.0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<213>";
				if(t_no_keys==1){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<214>";
					t_w3=dbg_object(t_bent).m_n_qw;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<215>";
					t_x3=dbg_object(t_bent).m_n_qx;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<216>";
					t_y3=dbg_object(t_bent).m_n_qy;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<217>";
					t_z3=dbg_object(t_bent).m_n_qz;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<219>";
					if(t_fd1+t_fd2==0.0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<222>";
						t_w3=t_w1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<223>";
						t_x3=t_x1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<224>";
						t_y3=t_y1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<225>";
						t_z3=t_z1;
					}else{
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<227>";
						var t_t:Number=1.0/(t_fd1+t_fd2)*t_fd1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<228>";
						t_quat=c_Quaternion.m_Slerp(t_x1,t_y1,t_z1,t_w1,t_x2,t_y2,t_z2,t_w2,t_t);
					}
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<231>";
				t_no_keys=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<233>";
				t_temp_vec.p_Update(t_px3,t_py3,t_pz3);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<235>";
				t_bent.p_Transform(t_temp_vec,t_quat,true);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<241>";
			m_VertexDeform(t_mesh);
		}
		popErr();
		return 0;
	}
	public static function m_AnimateVertex(t_ent:c_TEntity,t_frame:Number,t_start_frame:int,t_end_frame:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<257>";
		var t_vx:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<257>";
		var t_vy:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<257>";
		var t_vz:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<257>";
		var t_has_animation:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<259>";
		var t_mesh:c_TMesh=((t_ent) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<260>";
		if(!((t_ent)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<260>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<262>";
		if(t_frame>(t_end_frame)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<262>";
			t_frame=(t_end_frame);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<263>";
		if(t_frame<(t_start_frame)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<263>";
			t_frame=(t_start_frame);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<267>";
		var t_anim_surf:c_TSurface=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<268>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<268>";
		var t_:c_Enumerator6=dbg_object(t_mesh).m_surf_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<268>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<268>";
			var t_surf:c_TSurface=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<270>";
			t_anim_surf=t_mesh.p_GetAnimSurface(t_surf);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<271>";
			if(!((t_anim_surf)!=null)){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<271>";
				continue;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<273>";
			t_has_animation=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<274>";
			dbg_object(t_anim_surf).m_vbo_dyn=true;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<280>";
			if((dbg_array(dbg_object(t_anim_surf).m_vert_anim,((t_frame)|0))[dbg_index])!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<285>";
				dbg_array(dbg_object(t_mesh).m_anim_surf_frame,dbg_object(t_surf).m_surf_id)[dbg_index]=((t_frame)|0);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<286>";
				dbg_object(t_anim_surf).m_reset_vbo=dbg_object(t_anim_surf).m_reset_vbo|1;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<305>";
		if(t_has_animation){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<305>";
			dbg_object(t_mesh).m_anim_render=1;
		}
		popErr();
		return 0;
	}
	public static function m_AnimateMesh(t_ent1:c_TEntity,t_framef:Number,t_start_frame:int,t_end_frame:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<40>";
		var t_temp_vec:c_Vector=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<41>";
		var t_quat:c_Quaternion=(new c_Quaternion).m_Quaternion_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<43>";
		var t_mesh:c_TMesh=((t_ent1) as c_TMesh);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<45>";
		if(t_mesh!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<47>";
			if(dbg_object(t_mesh).m_anim==0 || t_mesh.p_Hidden()==true){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<47>";
				popErr();
				return 0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<49>";
			dbg_object(t_mesh).m_anim_render=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<52>";
			if(t_framef>(t_end_frame)){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<52>";
				t_framef=(t_end_frame);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<53>";
			if(t_framef<(t_start_frame)){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<53>";
				t_framef=(t_start_frame);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<56>";
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<56>";
			var t_:Array=dbg_object(t_mesh).m_bones;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<56>";
			var t_2:int=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<56>";
			while(t_2<t_.length){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<56>";
				var t_bent:c_TBone=dbg_array(t_,t_2)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<56>";
				t_2=t_2+1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<58>";
				if(!((t_bent)!=null)){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<58>";
					continue;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<62>";
				t_temp_vec=dbg_object(t_bent).m_keys.p_GetPosition(t_framef,t_start_frame,t_end_frame,true);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<65>";
				dbg_object(t_bent).m_kx=dbg_object(t_temp_vec).m_x;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<66>";
				dbg_object(t_bent).m_ky=dbg_object(t_temp_vec).m_y;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<67>";
				dbg_object(t_bent).m_kz=dbg_object(t_temp_vec).m_z;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<70>";
				t_quat=dbg_object(t_bent).m_keys.p_GetQuaternion(t_framef,t_start_frame,t_end_frame,true);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<74>";
				dbg_object(t_bent).m_kqw=dbg_object(t_quat).m_w;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<75>";
				dbg_object(t_bent).m_kqx=dbg_object(t_quat).m_x;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<76>";
				dbg_object(t_bent).m_kqy=dbg_object(t_quat).m_y;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<77>";
				dbg_object(t_bent).m_kqz=dbg_object(t_quat).m_z;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<79>";
				t_bent.p_Transform(t_temp_vec,t_quat,false);
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<84>";
			c_TBone.m_UpdateBoneChildren(t_mesh);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<87>";
			m_VertexDeform(t_mesh);
		}
		popErr();
		return 0;
	}
}
class c_Quaternion extends Object{
	public function m_Quaternion_new():c_Quaternion{
		pushErr();
		popErr();
		return this;
	}
	internal var m_x:Number=.0;
	internal var m_y:Number=.0;
	internal var m_z:Number=.0;
	internal var m_w:Number=.0;
	public function m_Quaternion_new2(t_xx:Number,t_yy:Number,t_zz:Number,t_ww:Number):c_Quaternion{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<14>";
		m_x=t_xx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<14>";
		m_y=t_yy;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<14>";
		m_z=t_zz;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<14>";
		m_w=t_ww;
		popErr();
		return this;
	}
	public static function m_Slerp(t_ax:Number,t_ay:Number,t_az:Number,t_aw:Number,t_bx:Number,t_by:Number,t_bz:Number,t_bw:Number,t_t:Number):c_Quaternion{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<266>";
		var t_var:c_Quaternion=(new c_Quaternion).m_Quaternion_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<268>";
		if(bb_math_Abs2(t_ax-t_bx)<0.001 && bb_math_Abs2(t_ay-t_by)<0.001 && bb_math_Abs2(t_az-t_bz)<0.001 && bb_math_Abs2(t_aw-t_bw)<0.001){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<269>";
			dbg_object(t_var).m_x=t_bx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<270>";
			dbg_object(t_var).m_y=t_by;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<271>";
			dbg_object(t_var).m_z=t_bz;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<272>";
			dbg_object(t_var).m_w=t_bw;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<273>";
			popErr();
			return t_var;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<276>";
		var t_cosineom:Number=t_ax*t_bx+t_ay*t_by+t_az*t_bz+t_aw*t_bw;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<277>";
		var t_scaler_w:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<278>";
		var t_scaler_x:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<279>";
		var t_scaler_y:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<280>";
		var t_scaler_z:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<282>";
		if(t_cosineom<=0.0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<283>";
			t_cosineom=-t_cosineom;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<284>";
			t_scaler_w=-t_bw;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<285>";
			t_scaler_x=-t_bx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<286>";
			t_scaler_y=-t_by;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<287>";
			t_scaler_z=-t_bz;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<289>";
			t_scaler_w=t_bw;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<290>";
			t_scaler_x=t_bx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<291>";
			t_scaler_y=t_by;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<292>";
			t_scaler_z=t_bz;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<296>";
		var t_scale0:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<297>";
		var t_scale1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<301>";
		if(1.0-t_cosineom>0.0001){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<302>";
			var t_omega:Number=(Math.acos(t_cosineom)*R2D);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<303>";
			var t_sineom:Number=1.0/Math.sin((t_omega)*D2R);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<305>";
			t_scale0=Math.sin(((1.0-t_t)*t_omega)*D2R)*t_sineom;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<306>";
			t_scale1=Math.sin((t_t*t_omega)*D2R)*t_sineom;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<309>";
			t_scale0=1.0-t_t;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<310>";
			t_scale1=t_t;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<313>";
		dbg_object(t_var).m_w=t_scale0*t_aw+t_scale1*t_scaler_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<314>";
		dbg_object(t_var).m_x=t_scale0*t_ax+t_scale1*t_scaler_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<315>";
		dbg_object(t_var).m_y=t_scale0*t_ay+t_scale1*t_scaler_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<316>";
		dbg_object(t_var).m_z=t_scale0*t_az+t_scale1*t_scaler_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<319>";
		popErr();
		return t_var;
	}
	public static function m_QuatToMatrix(t_x:Number,t_y:Number,t_z:Number,t_w:Number,t_mat:c_Matrix):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_x2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_xx2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_xy2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_xz2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_xw2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_y2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_yy2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_yz2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_yw2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_z2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_zz2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<160>";
		var t_zw2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<162>";
		t_x2=t_x+t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<163>";
		t_xx2=t_x2*t_x;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<164>";
		t_xy2=t_x2*t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<165>";
		t_xz2=t_x2*t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<166>";
		t_xw2=t_x2*t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<168>";
		t_y2=t_y+t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<169>";
		t_yy2=t_y2*t_y;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<170>";
		t_yz2=t_y2*t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<171>";
		t_yw2=t_y2*t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<173>";
		t_z2=t_z+t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<174>";
		t_zz2=t_z2*t_z;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<175>";
		t_zw2=t_z2*t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<177>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]=1.0-t_yy2-t_zz2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<178>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]=t_xy2-t_zw2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<179>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],2)[dbg_index]=t_xz2+t_yw2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<181>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]=t_xy2+t_zw2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<182>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]=1.0-t_xx2-t_zz2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<183>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],2)[dbg_index]=t_yz2-t_xw2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<185>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],0)[dbg_index]=t_xz2-t_yw2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<186>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],1)[dbg_index]=t_yz2+t_xw2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<187>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],2)[dbg_index]=1.0-t_xx2-t_yy2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<190>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<190>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<190>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],2)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<191>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<191>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<191>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,2)[dbg_index],3)[dbg_index]=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/quaternion.monkey<192>";
		dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],3)[dbg_index]=1.0;
		popErr();
	}
}
class c_TAnimationKeys extends Object{
	internal var m_flags:Array=new_number_array(1);
	internal var m_px:Array=new_number_array(1);
	internal var m_py:Array=new_number_array(1);
	internal var m_pz:Array=new_number_array(1);
	internal var m_qw:Array=new_number_array(1);
	internal var m_qx:Array=new_number_array(1);
	internal var m_qy:Array=new_number_array(1);
	internal var m_qz:Array=new_number_array(1);
	public function p_GetPosition(t_frame:Number,t_f_start:int,t_f_end:int,t_loop:Boolean):c_Vector{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<694>";
		var t_i:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<695>";
		var t_ii:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<696>";
		var t_fd1:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<697>";
		var t_fd2:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<698>";
		var t_found:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<699>";
		var t_no_keys:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<700>";
		var t_w1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<701>";
		var t_x1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<702>";
		var t_y1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<703>";
		var t_z1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<704>";
		var t_w2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<705>";
		var t_x2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<706>";
		var t_y2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<707>";
		var t_z2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<709>";
		var t_flag:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<714>";
		t_i=((t_frame)|0)+1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<716>";
		do{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<718>";
			t_i=t_i-1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<719>";
			t_flag=dbg_array(m_flags,t_i)[dbg_index]&1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<720>";
			if((t_flag)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<721>";
				t_x1=dbg_array(m_px,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<722>";
				t_y1=dbg_array(m_py,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<723>";
				t_z1=dbg_array(m_pz,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<724>";
				t_fd1=t_frame-(t_i);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<725>";
				t_found=true;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<727>";
			if(t_i<=t_f_start){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<727>";
				t_i=t_f_end+1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<727>";
				t_ii=t_ii+1;
			}
		}while(!(t_found==true || t_ii>=2));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<731>";
		if(t_found==false){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<731>";
			t_no_keys=true;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<732>";
		t_found=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<733>";
		t_ii=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<736>";
		t_i=((t_frame)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<737>";
		do{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<739>";
			t_i=t_i+1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<740>";
			if(t_i>t_f_end){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<740>";
				t_i=t_f_start;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<740>";
				t_ii=t_ii+1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<741>";
			t_flag=dbg_array(m_flags,t_i)[dbg_index]&1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<742>";
			if((t_flag)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<743>";
				t_x2=dbg_array(m_px,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<744>";
				t_y2=dbg_array(m_py,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<745>";
				t_z2=dbg_array(m_pz,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<746>";
				t_fd2=(t_i)-t_frame;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<747>";
				t_found=true;
			}
		}while(!(t_found==true || t_ii>=2));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<752>";
		if(t_found==false){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<752>";
			t_no_keys=true;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<753>";
		t_found=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<754>";
		t_ii=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<756>";
		var t_px3:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<757>";
		var t_py3:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<758>";
		var t_pz3:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<759>";
		if(t_no_keys==true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<760>";
			t_px3=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<761>";
			t_py3=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<762>";
			t_pz3=0.0;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<764>";
			if(t_fd1+t_fd2==0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<767>";
				t_px3=t_x1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<768>";
				t_py3=t_y1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<769>";
				t_pz3=t_z1;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<771>";
				var t_fd_inv:Number=1.0/(t_fd1+t_fd2);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<772>";
				t_px3=(t_x2-t_x1)*t_fd_inv*t_fd1+t_x1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<773>";
				t_py3=(t_y2-t_y1)*t_fd_inv*t_fd1+t_y1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<774>";
				t_pz3=(t_z2-t_z1)*t_fd_inv*t_fd1+t_z1;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<777>";
		t_no_keys=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<779>";
		var t_:c_Vector=(new c_Vector).m_Vector_new(t_px3,t_py3,t_pz3);
		popErr();
		return t_;
	}
	public function p_GetQuaternion(t_frame:Number,t_f_start:int,t_f_end:int,t_loop:Boolean):c_Quaternion{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<785>";
		var t_i:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<786>";
		var t_ii:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<787>";
		var t_fd1:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<788>";
		var t_fd2:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<789>";
		var t_found:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<790>";
		var t_no_keys:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<791>";
		var t_w1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<792>";
		var t_x1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<793>";
		var t_y1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<794>";
		var t_z1:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<795>";
		var t_w2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<796>";
		var t_x2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<797>";
		var t_y2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<798>";
		var t_z2:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<799>";
		var t_flag:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<801>";
		var t_quat:c_Quaternion=(new c_Quaternion).m_Quaternion_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<803>";
		t_i=((t_frame)|0)+1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<804>";
		do{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<805>";
			t_i=t_i-1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<806>";
			t_flag=dbg_array(m_flags,t_i)[dbg_index]&4;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<807>";
			if((t_flag)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<808>";
				t_w1=dbg_array(m_qw,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<809>";
				t_x1=dbg_array(m_qx,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<810>";
				t_y1=dbg_array(m_qy,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<811>";
				t_z1=dbg_array(m_qz,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<812>";
				t_fd1=t_frame-(t_i);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<813>";
				t_found=true;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<815>";
			if(t_i<=t_f_start){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<815>";
				t_i=t_f_end+1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<815>";
				t_ii=t_ii+1;
			}
		}while(!(t_found==true || t_ii>=2));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<818>";
		if(t_found==false){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<818>";
			t_no_keys=true;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<819>";
		t_found=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<820>";
		t_ii=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<823>";
		t_i=((t_frame)|0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<825>";
		do{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<826>";
			t_i=t_i+1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<827>";
			if(t_i>t_f_end){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<827>";
				t_i=t_f_start;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<827>";
				t_ii=t_ii+1;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<828>";
			t_flag=dbg_array(m_flags,t_i)[dbg_index]&4;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<829>";
			if((t_flag)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<830>";
				t_w2=dbg_array(m_qw,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<831>";
				t_x2=dbg_array(m_qx,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<832>";
				t_y2=dbg_array(m_qy,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<833>";
				t_z2=dbg_array(m_qz,t_i)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<834>";
				t_fd2=(t_i)-t_frame;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<835>";
				t_found=true;
			}
		}while(!(t_found==true || t_ii>=2));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<839>";
		if(t_found==false){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<839>";
			t_no_keys=true;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<840>";
		t_found=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<841>";
		t_ii=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<845>";
		var t_w3:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<846>";
		var t_x3:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<847>";
		var t_y3:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<848>";
		var t_z3:Number=0.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<849>";
		if(t_no_keys==true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<850>";
			dbg_object(t_quat).m_w=1.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<851>";
			dbg_object(t_quat).m_x=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<852>";
			dbg_object(t_quat).m_y=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<853>";
			dbg_object(t_quat).m_z=0.0;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<855>";
			if(t_fd1+t_fd2==0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<858>";
				dbg_object(t_quat).m_w=t_w1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<859>";
				dbg_object(t_quat).m_x=t_x1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<860>";
				dbg_object(t_quat).m_y=t_y1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<861>";
				dbg_object(t_quat).m_z=t_z1;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<863>";
				var t_t:Number=1.0/(t_fd1+t_fd2)*t_fd1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<864>";
				t_quat=c_Quaternion.m_Slerp(t_x1,t_y1,t_z1,t_w1,t_x2,t_y2,t_z2,t_w2,t_t);
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tanimation.monkey<868>";
		popErr();
		return t_quat;
	}
}
class c_FloatBuffer extends Object{
	internal var m_buf:c_DataBuffer=null;
}
class c_TVertexAnim extends c_FloatBuffer{
}
internal function bb_functions_UpdateWorld(t_anim_speed:Number):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<1369>";
	c_TRender.m_UpdateWorld(t_anim_speed);
	popErr();
	return 0;
}
class c_Enumerator10 extends Object{
	internal var m_stack:c_Stack3=null;
	public function m_Enumerator_new(t_stack:c_Stack3):c_Enumerator10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<255>";
		dbg_object(this).m_stack=t_stack;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator10{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<252>";
		popErr();
		return this;
	}
	internal var m_index:int=0;
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<259>";
		var t_:Boolean=m_index<m_stack.p_Length();
		popErr();
		return t_;
	}
	public function p_NextObject():c_TTexture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<263>";
		m_index+=1;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/stack.monkey<264>";
		var t_:c_TTexture=dbg_array(dbg_object(m_stack).m_data,m_index-1)[dbg_index];
		popErr();
		return t_;
	}
}
class c_Enumerator11 extends Object{
	internal var m__list:c_List4=null;
	internal var m__curr:c_Node5=null;
	public function m_Enumerator_new(t_list:c_List4):c_Enumerator11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator11{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TCamera{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TCamera=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_TShader extends c_TBrush{
	internal static var m_process_list:c_List13;
	public static function m_PreProcess(t_cam:c_TCamera):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<74>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<74>";
		var t_:c_Enumerator12=m_process_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<74>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<74>";
			var t_sh:c_TShader=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<75>";
			((t_sh) as c_IShaderProcess).p_PreProcess(t_cam);
		}
		popErr();
		return 0;
	}
	internal static var m_g_shader:c_TShader;
	public static function m_PostProcess(t_cam:c_TCamera):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<82>";
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<82>";
		var t_:c_Enumerator12=m_process_list.p_ObjectEnumerator();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<82>";
		while(t_.p_HasNext()){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<82>";
			var t_sh:c_TShader=t_.p_NextObject();
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<83>";
			((t_sh) as c_IShaderProcess).p_PostProcess(t_cam);
		}
		popErr();
		return 0;
	}
	public function m_TShader_new():c_TShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<18>";
		super.m_TBrush_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<18>";
		popErr();
		return this;
	}
	public function p_CompileShader(t_source:String,t_type:int):int{
		return 0;
	}
	internal var m_vertex_id:int=0;
	internal var m_fragment_id:int=0;
	internal var m_shader_id:int=0;
	internal var m_active:int=0;
	public function p_ResetShader():int{
		return 0;
	}
	public static function m_LoadDefaultShader(t_vp_file:String,t_fp_file:String):c_TShader{
		pushErr();
		popErr();
		return null;
	}
	internal static var m_default_shader:c_TShader;
	public static function m_SetShader(t_sh:c_TShader):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<106>";
		if((m_g_shader)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<106>";
			dbg_object(m_g_shader).m_active=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<107>";
		m_g_shader=t_sh;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<108>";
		dbg_object(m_g_shader).m_active=1;
		popErr();
		return 0;
	}
	public static function m_LoadDefaultShader2(t_sh:c_TShader):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<57>";
		m_default_shader=t_sh;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<58>";
		m_SetShader(m_default_shader);
		popErr();
	}
	public static function m_DefaultShader():c_TShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<118>";
		if(!((m_g_shader)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<118>";
			popErr();
			return null;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<120>";
		dbg_object(m_g_shader).m_active=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<121>";
		m_g_shader=m_default_shader;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<122>";
		dbg_object(m_g_shader).m_active=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/tshader.monkey<124>";
		popErr();
		return m_default_shader;
	}
	public function p_Update12():int{
		pushErr();
		popErr();
		return 0;
	}
	public override function p_Copy():c_TBrush{
		return null;
	}
	internal var m_override:Boolean=false;
}
class c_List13 extends Object{
	public function m_List_new():c_List13{
		pushErr();
		popErr();
		return this;
	}
	internal var m__head:c_Node16=((new c_HeadNode13).m_HeadNode_new());
	public function p_AddLast13(t_data:c_TShader):c_Node16{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<108>";
		var t_:c_Node16=(new c_Node16).m_Node_new(m__head,dbg_object(m__head).m__pred,t_data);
		popErr();
		return t_;
	}
	public function m_List_new2(t_data:Array):c_List13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_:Array=t_data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		var t_2:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
		while(t_2<t_.length){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			var t_t:c_TShader=dbg_array(t_,t_2)[dbg_index];
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<13>";
			t_2=t_2+1;
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<14>";
			this.p_AddLast13(t_t);
		}
		popErr();
		return this;
	}
	public function p_ObjectEnumerator():c_Enumerator12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<186>";
		var t_:c_Enumerator12=(new c_Enumerator12).m_Enumerator_new(this);
		popErr();
		return t_;
	}
}
class c_Node16 extends Object{
	internal var m__succ:c_Node16=null;
	internal var m__pred:c_Node16=null;
	internal var m__data:c_TShader=null;
	public function m_Node_new(t_succ:c_Node16,t_pred:c_Node16,t_data:c_TShader):c_Node16{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<261>";
		m__succ=t_succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<262>";
		m__pred=t_pred;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<263>";
		dbg_object(m__succ).m__pred=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<264>";
		dbg_object(m__pred).m__succ=this;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<265>";
		m__data=t_data;
		popErr();
		return this;
	}
	public function m_Node_new2():c_Node16{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<258>";
		popErr();
		return this;
	}
}
class c_HeadNode13 extends c_Node16{
	public function m_HeadNode_new():c_HeadNode13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<310>";
		super.m_Node_new2();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<311>";
		m__succ=(this);
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<312>";
		m__pred=(this);
		popErr();
		return this;
	}
}
class c_Enumerator12 extends Object{
	internal var m__list:c_List13=null;
	internal var m__curr:c_Node16=null;
	public function m_Enumerator_new(t_list:c_List13):c_Enumerator12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator12{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TShader=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
interface c_IShaderProcess{
	function p_PreProcess(t_cam:c_TCamera):int;
	function p_PostProcess(t_cam:c_TCamera):int;
}
interface c_IShaderRender extends c_IShaderProcess{
	function p_Render2(t_cam:c_TCamera):int;
}
class c_Enumerator13 extends Object{
	internal var m__list:c_List5=null;
	internal var m__curr:c_Node6=null;
	public function m_Enumerator_new(t_list:c_List5):c_Enumerator13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator13{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TLight{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TLight=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
class c_RenderAlphaList extends c_List3{
	public function m_RenderAlphaList_new():c_RenderAlphaList{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<792>";
		super.m_List_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<792>";
		popErr();
		return this;
	}
	public override function p_Compare2(t_left:c_TMesh,t_right:c_TMesh):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<796>";
		if(dbg_object(t_left).m_alpha_order>dbg_object(t_right).m_alpha_order){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<796>";
			popErr();
			return -1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<797>";
		var t_:int=((dbg_object(t_left).m_alpha_order<dbg_object(t_right).m_alpha_order)?1:0);
		popErr();
		return t_;
	}
}
class c_Enumerator14 extends Object{
	internal var m__list:c_List3=null;
	internal var m__curr:c_Node4=null;
	public function m_Enumerator_new(t_list:c_List3):c_Enumerator14{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<326>";
		m__list=t_list;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<327>";
		m__curr=dbg_object(dbg_object(t_list).m__head).m__succ;
		popErr();
		return this;
	}
	public function m_Enumerator_new2():c_Enumerator14{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<323>";
		popErr();
		return this;
	}
	public function p_HasNext():Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<331>";
		while(dbg_object(dbg_object(m__curr).m__succ).m__pred!=m__curr){
			_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<332>";
			m__curr=dbg_object(m__curr).m__succ;
		}
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<334>";
		var t_:Boolean=m__curr!=dbg_object(m__list).m__head;
		popErr();
		return t_;
	}
	public function p_NextObject():c_TMesh{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<338>";
		var t_data:c_TMesh=dbg_object(m__curr).m__data;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<339>";
		m__curr=dbg_object(m__curr).m__succ;
		_errInfo="C:/MonkeyXPro77f/modules/monkey/list.monkey<340>";
		popErr();
		return t_data;
	}
}
internal function bb_functions_RenderWorld():int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<1144>";
	c_TRender.m_RenderWorld();
	popErr();
	return 0;
}
class c_TShaderFlash extends c_TShader{
	internal static var m_driver:Driver3D;
	internal static var m_g_id:int;
	internal var m_vertex_assembly:AGALMiniAssembler=null;
	internal var m_vertex_code:ByteArray=null;
	internal var m_fragment_assembly:AGALMiniAssembler=null;
	internal var m_fragment_code:ByteArray=null;
	public override function p_CompileShader(t_source:String,t_type:int):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<300>";
		if(t_source.length<2){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<301>";
			print("**Shader file not found");
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<302>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<305>";
		var t_verbose:Boolean=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<308>";
		t_verbose=false;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<311>";
		var t_result:ByteArray=null;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<313>";
		if(t_type==1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<315>";
			m_vertex_id=m_g_id;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<316>";
			m_vertex_assembly=(new AGALMiniAssembler(false));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<317>";
			m_vertex_code=m_vertex_assembly.assemble(Context3DProgramType.VERTEX,t_source,t_verbose);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<318>";
			t_result=m_vertex_code;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<322>";
		if(t_type==2){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<324>";
			m_fragment_id=m_g_id;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<325>";
			m_fragment_assembly=(new AGALMiniAssembler(false));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<326>";
			m_fragment_code=m_fragment_assembly.assemble(Context3DProgramType.FRAGMENT,t_source,t_verbose);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<327>";
			t_result=m_fragment_code;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<331>";
		var t_ll:int=t_result.length; //();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<334>";
		if(!((t_result)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<336>";
			print("**Shader Compiler Error");
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<338>";
			if(t_type==1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<338>";
				m_vertex_id=0;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<338>";
				m_fragment_id=0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<340>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<343>";
		m_g_id+=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<345>";
		popErr();
		return 1;
	}
	internal var m_program_set:Program3D=null;
	internal var m_u:c_ShaderUniforms=null;
	public function p_LinkVariables():int{
		pushErr();
		popErr();
		return 0;
	}
	public function p_LinkShader():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<264>";
		m_program_set=m_driver.context3d.createProgram();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<266>";
		try{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<267>";
			m_program_set.upload(m_vertex_code,m_fragment_code);
		}catch(t_e:Error){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<269>";
			print(t_e.toString());
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<270>";
			error("");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<273>";
		try{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<275>";
			m_driver.context3d.setProgram(m_program_set);
		}catch(t_e2:Error){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<279>";
			print(t_e2.toString());
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<281>";
			m_vertex_id=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<281>";
			m_fragment_id=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<281>";
			m_shader_id=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<283>";
			print("**Error: Program Link not created.");
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<283>";
			popErr();
			return 0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<287>";
		m_active=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<290>";
		m_u=(new c_ShaderUniforms).m_ShaderUniforms_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<291>";
		this.p_LinkVariables();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<293>";
		popErr();
		return 1;
	}
	public static function m_LoadShaderString(t_vp:String,t_fp:String,t_shader:c_TShaderFlash):c_TShaderFlash{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<373>";
		var t_fail:int=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<376>";
		if(!((t_shader)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<376>";
			t_shader=(new c_TShaderFlash).m_TShaderFlash_new("","");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<378>";
		var t_vs:int=t_shader.p_CompileShader(t_vp,1);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<379>";
		var t_fs:int=t_shader.p_CompileShader(t_fp,2);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<380>";
		if(((t_vs)!=0) && ((t_fs)!=0)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<382>";
			if(true){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<382>";
				print("..shader compile success");
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<384>";
			if((t_shader.p_LinkShader())!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<384>";
				t_fail=0;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<388>";
		if(!((t_fail)!=0)){
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<391>";
			print("**compiler error");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<394>";
		popErr();
		return t_shader;
	}
	public function m_TShaderFlash_new(t_vp:String,t_fp:String):c_TShaderFlash{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<166>";
		super.m_TShader_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<168>";
		m_driver=c_FlashMiniB3D.m_driver;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<169>";
		if(t_vp!="" && t_fp!=""){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<170>";
			m_LoadShaderString(t_vp,t_fp,this);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<173>";
			if((m_shader_id)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<174>";
				m_active=1;
			}
		}
		popErr();
		return this;
	}
	public override function p_ResetShader():int{
		pushErr();
		popErr();
		return 0;
	}
	internal var m_use_base_variables:int=1;
	public override function p_Copy():c_TBrush{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<184>";
		var t_brush:c_TShaderFlash=(new c_TShaderFlash).m_TShaderFlash_new("","");
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<186>";
		dbg_object(t_brush).m_no_texs=m_no_texs;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<187>";
		dbg_object(t_brush).m_name=m_name;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<188>";
		dbg_object(t_brush).m_red=m_red;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<189>";
		dbg_object(t_brush).m_green=m_green;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<190>";
		dbg_object(t_brush).m_blue=m_blue;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<191>";
		dbg_object(t_brush).m_alpha=m_alpha;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<192>";
		dbg_object(t_brush).m_shine=m_shine;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<193>";
		dbg_object(t_brush).m_blend=m_blend;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<194>";
		dbg_object(t_brush).m_fx=m_fx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<195>";
		dbg_array(dbg_object(t_brush).m_tex,0)[dbg_index]=dbg_array(m_tex,0)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<196>";
		dbg_array(dbg_object(t_brush).m_tex,1)[dbg_index]=dbg_array(m_tex,1)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<197>";
		dbg_array(dbg_object(t_brush).m_tex,2)[dbg_index]=dbg_array(m_tex,2)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<198>";
		dbg_array(dbg_object(t_brush).m_tex,3)[dbg_index]=dbg_array(m_tex,3)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<199>";
		dbg_array(dbg_object(t_brush).m_tex,4)[dbg_index]=dbg_array(m_tex,4)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<200>";
		dbg_array(dbg_object(t_brush).m_tex,5)[dbg_index]=dbg_array(m_tex,5)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<201>";
		dbg_array(dbg_object(t_brush).m_tex,6)[dbg_index]=dbg_array(m_tex,6)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<202>";
		dbg_array(dbg_object(t_brush).m_tex,7)[dbg_index]=dbg_array(m_tex,7)[dbg_index];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<204>";
		dbg_object(t_brush).m_shader_id=m_shader_id;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<205>";
		dbg_object(t_brush).m_fragment_id=m_fragment_id;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<206>";
		dbg_object(t_brush).m_vertex_id=m_vertex_id;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<207>";
		dbg_object(t_brush).m_u=m_u;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<208>";
		dbg_object(t_brush).m_override=m_override;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<210>";
		dbg_object(t_brush).m_active=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<211>";
		t_brush.p_LinkVariables();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<212>";
		dbg_object(t_brush).m_active=m_active;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<214>";
		dbg_object(t_brush).m_use_base_variables=m_use_base_variables;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<216>";
		var t_:c_TBrush=(t_brush);
		popErr();
		return t_;
	}
}
class c_MultiShader extends c_TShaderFlash{
	internal static var m_init:Boolean;
	internal var m_shader:Array=new_object_array(8);
	public override function p_ResetShader():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<451>";
		dbg_array(m_shader,0)[dbg_index]=((new c_FullBrightOneTexShader).m_FullBrightOneTexShader_new("clamp",c_FullBrightOneTexShader.m_VP,c_FullBrightOneTexShader.m_FP));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<452>";
		dbg_array(m_shader,1)[dbg_index]=((new c_FullBrightOneTexShader).m_FullBrightOneTexShader_new("repeat",c_FullBrightOneTexShader.m_VP,c_FullBrightOneTexShader.m_FP));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<453>";
		dbg_array(m_shader,2)[dbg_index]=((new c_OneLightOneTexShader).m_OneLightOneTexShader_new("clamp",c_OneLightOneTexShader.m_VP,c_OneLightOneTexShader.m_FP));
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<454>";
		dbg_array(m_shader,3)[dbg_index]=((new c_OneLightOneTexShader).m_OneLightOneTexShader_new("repeat",c_OneLightOneTexShader.m_VP,c_OneLightOneTexShader.m_FP));
		popErr();
		return 0;
	}
	public function m_MultiShader_new():c_MultiShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<436>";
		super.m_TShaderFlash_new("","");
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<437>";
		if(m_init){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<437>";
			popErr();
			return this;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<438>";
		m_init=true;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<440>";
		this.p_ResetShader();
		popErr();
		return this;
	}
	public function p_GetShader(t_i:int):c_TShaderFlash{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<461>";
		popErr();
		return dbg_array(m_shader,t_i)[dbg_index];
	}
}
class c_ShaderUniforms extends Object{
	public function m_ShaderUniforms_new():c_ShaderUniforms{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<18>";
		popErr();
		return this;
	}
	internal var m_vertcoords:int=0;
	internal var m_normals:int=0;
	internal var m_colors:int=0;
	internal var m_texcoords0:int=0;
	internal var m_texcoords1:int=0;
	internal var m_tex_position:Array=new_number_array(9);
	internal var m_tex_scale:Array=new_number_array(9);
	internal var m_m_matrix:int=0;
	internal var m_n_matrix:int=0;
	internal var m_p_matrix:int=0;
	internal var m_light_matrix:Array=new_number_array(9);
	internal var m_lightflag:int=0;
	internal var m_light_color:Array=new_number_array(9);
	internal var m_light_att:Array=new_number_array(9);
	internal var m_colorflag:int=0;
	internal var m_base_color:int=0;
	internal var m_ambient_color:int=0;
	internal var m_miscflag:int=0;
	internal var m_tex_blend:Array=new_number_array(9);
	internal var m_light_spot:Array=new_number_array(9);
}
class c_OneLightOneTexShader extends c_TShaderFlash{
	internal static var m_VP:String;
	internal static var m_FP:String;
	internal static var m_alphaTest:String;
	public function m_OneLightOneTexShader_new(t_tex_clamp:String,t_vp:String,t_fp:String):c_OneLightOneTexShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<573>";
		super.m_TShaderFlash_new("","");
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<576>";
		t_fp=bb_tshader_flash_StringReplace("TEXTURE_WRAP",t_tex_clamp,t_fp);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<577>";
		t_fp=bb_tshader_flash_StringReplace("ALPHATEST",m_alphaTest,t_fp);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<579>";
		c_TShaderFlash.m_driver=c_FlashMiniB3D.m_driver;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<580>";
		if(t_vp!="" && t_fp!=""){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<581>";
			c_TShaderFlash.m_LoadShaderString(t_vp,t_fp,(this));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<584>";
			if((m_shader_id)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<585>";
				m_active=1;
			}
		}
		popErr();
		return this;
	}
	public function m_OneLightOneTexShader_new2():c_OneLightOneTexShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<467>";
		super.m_TShaderFlash_new("","");
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<467>";
		popErr();
		return this;
	}
	public override function p_LinkVariables():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<542>";
		m_active=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<544>";
		dbg_object(m_u).m_vertcoords=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<545>";
		dbg_object(m_u).m_texcoords0=2;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<546>";
		dbg_object(m_u).m_texcoords1=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<547>";
		dbg_object(m_u).m_normals=3;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<548>";
		dbg_object(m_u).m_colors=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<551>";
		dbg_object(m_u).m_p_matrix=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<552>";
		dbg_object(m_u).m_m_matrix=4;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<553>";
		dbg_object(m_u).m_n_matrix=8;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<554>";
		dbg_array(dbg_object(m_u).m_light_matrix,0)[dbg_index]=12;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<555>";
		dbg_object(m_u).m_base_color=16;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<556>";
		dbg_object(m_u).m_ambient_color=17;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<557>";
		dbg_array(dbg_object(m_u).m_light_color,0)[dbg_index]=22;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<559>";
		dbg_array(dbg_object(m_u).m_tex_position,0)[dbg_index]=23;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<560>";
		dbg_array(dbg_object(m_u).m_tex_scale,0)[dbg_index]=24;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<561>";
		dbg_array(dbg_object(m_u).m_tex_blend,0)[dbg_index]=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<564>";
		dbg_object(m_u).m_colorflag=18;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<565>";
		dbg_object(m_u).m_miscflag=25;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<566>";
		dbg_object(m_u).m_lightflag=26;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<568>";
		dbg_array(dbg_object(m_u).m_light_att,0)[dbg_index]=27;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<569>";
		dbg_array(dbg_object(m_u).m_light_spot,0)[dbg_index]=28;
		popErr();
		return 0;
	}
}
class c_FullBrightOneTexShader extends c_OneLightOneTexShader{
	internal static var m_VP:String;
	internal static var m_FP:String;
	internal static var m_alphaTest:String;
	public function m_FullBrightOneTexShader_new(t_tex_clamp:String,t_vp:String,t_fp:String):c_FullBrightOneTexShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<656>";
		super.m_OneLightOneTexShader_new2();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<659>";
		t_fp=bb_tshader_flash_StringReplace("TEXTURE_WRAP",t_tex_clamp,t_fp);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<660>";
		t_fp=bb_tshader_flash_StringReplace("ALPHATEST",m_alphaTest,t_fp);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<662>";
		c_TShaderFlash.m_driver=c_FlashMiniB3D.m_driver;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<663>";
		if(t_vp!="" && t_fp!=""){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<664>";
			c_TShaderFlash.m_LoadShaderString(t_vp,t_fp,(this));
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<667>";
			if((m_shader_id)!=0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<668>";
				m_active=1;
			}
		}
		popErr();
		return this;
	}
	public function m_FullBrightOneTexShader_new2():c_FullBrightOneTexShader{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<595>";
		super.m_OneLightOneTexShader_new2();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<595>";
		popErr();
		return this;
	}
	public override function p_LinkVariables():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<651>";
		super.p_LinkVariables();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<652>";
		dbg_array(dbg_object(m_u).m_light_matrix,0)[dbg_index]=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<653>";
		dbg_array(dbg_object(m_u).m_light_color,0)[dbg_index]=-1;
		popErr();
		return 0;
	}
}
internal function bb_tshader_flash_StringReplace(t_r:String,t_n:String,t_st:String):String{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<678>";
	var t_a:Array=t_st.split(t_r);
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<679>";
	if(t_a.length==2){
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<679>";
		t_st=dbg_array(t_a,0)[dbg_index]+t_n+dbg_array(t_a,1)[dbg_index];
	}else{
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<679>";
		print("**Shader error: string replace");
	}
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tshader_flash.monkey<680>";
	popErr();
	return t_st;
}
class c_EffectState extends Object{
	public function m_EffectState_new():c_EffectState{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<542>";
		popErr();
		return this;
	}
	internal var m_use_full_bright:int=0;
	internal var m_use_vertex_colors:int=0;
	internal var m_use_flatshade:int=0;
	internal var m_use_fog:int=1;
	internal var m_ambient:Array=[1.0,1.0,1.0,1.0];
	internal var m_diffuse:Array=[1.0,1.0,1.0,1.0];
	internal var m_specular:Array=[1.0,1.0,1.0,1.0];
	internal var m_shininess:Array=[100.0];
	internal var m_use_depth_test:int=0;
	internal var m_use_depth_write:int=0;
	internal var m_use_backface_culling:int=0;
	internal var m_use_alpha_test:int=0;
	internal var m_use_perpixellighting:int=0;
	internal var m_red:Number=.0;
	internal var m_green:Number=.0;
	internal var m_blue:Number=.0;
	internal var m_alpha:Number=.0;
	internal var m_shine:Number=.0;
	internal var m_blend:int=0;
	internal var m_fx:int=0;
	internal var m_num_tex:int=0;
	public function p_SetNull():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<595>";
		m_use_full_bright=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<596>";
		m_use_vertex_colors=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<597>";
		m_use_flatshade=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<598>";
		m_use_fog=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<599>";
		m_ambient=[-1.0,-1.0,-1.0,1.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<603>";
		m_diffuse=[-1.0,-1.0,-1.0,1.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<604>";
		m_specular=[-1.0,-1.0,-1.0,1.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<605>";
		m_shininess=[-1.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<607>";
		m_use_depth_test=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<608>";
		m_use_depth_write=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<609>";
		m_use_backface_culling=-1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<610>";
		m_use_alpha_test=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<611>";
		m_use_perpixellighting=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<612>";
		m_red=-1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<612>";
		m_green=-1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<612>";
		m_blue=-1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<612>";
		m_alpha=-1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<613>";
		m_shine=-1.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<613>";
		m_blend=99999;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<613>";
		m_fx=99999;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<615>";
		m_num_tex=-1;
		popErr();
	}
	internal var m_tex:Array=[];
	public function p_UpdateEffect(t_surf:c_TSurface,t_ent:c_TEntity,t_cam:c_TCamera):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<622>";
		var t_ambient_red:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<622>";
		var t_ambient_green:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<622>";
		var t_ambient_blue:Number=.0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<625>";
		m_red=dbg_object(dbg_object(t_ent).m_brush).m_red;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<626>";
		m_green=dbg_object(dbg_object(t_ent).m_brush).m_green;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<627>";
		m_blue=dbg_object(dbg_object(t_ent).m_brush).m_blue;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<628>";
		m_alpha=dbg_object(dbg_object(t_ent).m_brush).m_alpha;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<629>";
		m_shine=dbg_object(dbg_object(t_ent).m_brush).m_shine;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<630>";
		m_blend=dbg_object(dbg_object(t_ent).m_brush).m_blend;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<631>";
		m_fx=dbg_object(dbg_object(t_ent).m_brush).m_fx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<632>";
		m_num_tex=dbg_object(dbg_object(t_ent).m_brush).m_no_texs;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<633>";
		m_tex=dbg_object(dbg_object(t_ent).m_brush).m_tex;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<636>";
		if((dbg_object(t_surf).m_brush)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<638>";
			var t_shine2:Number=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<640>";
			m_red=m_red*dbg_object(dbg_object(t_surf).m_brush).m_red;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<641>";
			m_green=m_green*dbg_object(dbg_object(t_surf).m_brush).m_green;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<642>";
			m_blue=m_blue*dbg_object(dbg_object(t_surf).m_brush).m_blue;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<643>";
			m_alpha=m_alpha*dbg_object(dbg_object(t_surf).m_brush).m_alpha;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<644>";
			t_shine2=dbg_object(dbg_object(t_surf).m_brush).m_shine;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<645>";
			if(m_shine==0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<645>";
				m_shine=t_shine2;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<646>";
			if(m_shine!=0.0 && t_shine2!=0.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<646>";
				m_shine=m_shine*t_shine2;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<647>";
			if(m_blend==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<647>";
				m_blend=dbg_object(dbg_object(t_surf).m_brush).m_blend;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<648>";
			m_fx=m_fx|dbg_object(dbg_object(t_surf).m_brush).m_fx;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<649>";
			if(m_num_tex<dbg_object(dbg_object(t_surf).m_brush).m_no_texs){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<650>";
				m_num_tex=dbg_object(dbg_object(t_surf).m_brush).m_no_texs;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<651>";
				m_tex=dbg_object(dbg_object(t_surf).m_brush).m_tex;
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<656>";
		m_alpha=m_alpha-dbg_object(t_ent).m_fade_alpha;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<658>";
		m_use_depth_test=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<659>";
		m_use_depth_write=1;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<662>";
		var t_enable_blend:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<663>";
		if(dbg_object(t_ent).m_using_alpha==true){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<665>";
			if(dbg_object(dbg_object(t_ent).m_brush).m_alpha<1.0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<667>";
				t_enable_blend=1;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<669>";
				m_use_depth_write=0;
			}else{
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<670>";
				if(dbg_object(t_surf).m_alpha_enable==true){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<672>";
					t_enable_blend=1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<674>";
					m_use_depth_write=0;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<677>";
					t_enable_blend=0;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<678>";
					m_use_depth_test=1;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<679>";
					m_use_depth_write=1;
				}
			}
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<683>";
			t_enable_blend=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<688>";
		if(t_enable_blend==0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<688>";
			m_blend=-1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<690>";
		m_use_vertex_colors=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<691>";
		m_use_flatshade=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<692>";
		m_use_fog=((dbg_object(t_cam).m_fog_mode>0)?1:0);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<695>";
		if((m_fx&1)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<696>";
			t_ambient_red=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<696>";
			t_ambient_green=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<696>";
			t_ambient_blue=0.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<697>";
			m_use_full_bright=1;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<699>";
			t_ambient_red=c_TLight.m_ambient_red;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<700>";
			t_ambient_green=c_TLight.m_ambient_green;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<701>";
			t_ambient_blue=c_TLight.m_ambient_blue;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<702>";
			m_use_full_bright=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<707>";
		if((m_fx&2)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<708>";
			m_use_vertex_colors=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<709>";
			m_red=1.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<709>";
			m_green=1.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<709>";
			m_blue=1.0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<709>";
			m_alpha=1.0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<713>";
		if((m_fx&4)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<714>";
			m_use_flatshade=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<718>";
		if((m_fx&8)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<719>";
			m_use_fog=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<723>";
		if((m_fx&16)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<724>";
			m_use_backface_culling=0;
		}else{
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<727>";
			m_use_backface_culling=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<734>";
		if((m_fx&64)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<736>";
			m_use_depth_test=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<737>";
			m_use_depth_write=0;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<741>";
		m_use_alpha_test=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<743>";
		var t_tex_alphatest:int=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<744>";
		if(m_num_tex>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<745>";
			for(var t_i:int=0;t_i<=m_num_tex-1;t_i=t_i+1){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<746>";
				if((dbg_array(m_tex,t_i)[dbg_index])!=null){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<746>";
					t_tex_alphatest|=dbg_object(dbg_array(m_tex,t_i)[dbg_index]).m_flags&4;
				}
			}
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<750>";
		if((m_fx&128)>0 || t_tex_alphatest>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<751>";
			m_use_alpha_test=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<752>";
			m_use_depth_test=1;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<753>";
			m_use_depth_write=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<756>";
		if((m_fx&256)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<757>";
			m_use_perpixellighting=1;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<762>";
		m_ambient=[t_ambient_red,t_ambient_green,t_ambient_blue,0.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<765>";
		m_diffuse=[m_red,m_green,m_blue,m_alpha];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<766>";
		m_specular=[m_shine,m_shine,m_shine,1.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<767>";
		m_shininess=[100.0];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<769>";
		if((dbg_object(t_cam).m_draw2D)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<772>";
			if((m_fx&64)==0){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<772>";
				m_use_depth_test=0;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<772>";
				m_use_depth_write=0;
			}
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<774>";
			m_use_fog=0;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<776>";
			m_use_full_bright=1;
		}
		popErr();
	}
	public function p_Overwrite4(t_e:c_EffectState):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<571>";
		m_use_full_bright=dbg_object(t_e).m_use_full_bright;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<572>";
		m_use_vertex_colors=dbg_object(t_e).m_use_vertex_colors;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<573>";
		m_use_flatshade=dbg_object(t_e).m_use_flatshade;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<574>";
		m_use_fog=dbg_object(t_e).m_use_fog;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<575>";
		m_ambient=[dbg_array(dbg_object(t_e).m_ambient,0)[dbg_index],dbg_array(dbg_object(t_e).m_ambient,1)[dbg_index],dbg_array(dbg_object(t_e).m_ambient,2)[dbg_index],dbg_array(dbg_object(t_e).m_ambient,3)[dbg_index]];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<579>";
		m_diffuse=[dbg_array(dbg_object(t_e).m_diffuse,0)[dbg_index],dbg_array(dbg_object(t_e).m_diffuse,1)[dbg_index],dbg_array(dbg_object(t_e).m_diffuse,2)[dbg_index],dbg_array(dbg_object(t_e).m_diffuse,3)[dbg_index]];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<580>";
		m_specular=[dbg_array(dbg_object(t_e).m_specular,0)[dbg_index],dbg_array(dbg_object(t_e).m_specular,1)[dbg_index],dbg_array(dbg_object(t_e).m_specular,2)[dbg_index],dbg_array(dbg_object(t_e).m_specular,3)[dbg_index]];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<581>";
		m_shininess=[dbg_array(dbg_object(t_e).m_shininess,0)[dbg_index]];
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<583>";
		m_use_depth_test=dbg_object(t_e).m_use_depth_test;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<584>";
		m_use_depth_write=dbg_object(t_e).m_use_depth_write;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<585>";
		m_use_backface_culling=dbg_object(t_e).m_use_backface_culling;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<586>";
		m_red=dbg_object(t_e).m_red;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<586>";
		m_green=dbg_object(t_e).m_green;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<586>";
		m_blue=dbg_object(t_e).m_blue;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<586>";
		m_alpha=dbg_object(t_e).m_alpha;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<587>";
		m_shine=dbg_object(t_e).m_shine;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<587>";
		m_blend=dbg_object(t_e).m_blend;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<587>";
		m_fx=dbg_object(t_e).m_fx;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<588>";
		m_use_alpha_test=dbg_object(t_e).m_use_alpha_test;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<589>";
		m_use_perpixellighting=dbg_object(t_e).m_use_perpixellighting;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<591>";
		m_num_tex=dbg_object(t_e).m_num_tex;
		popErr();
	}
}
class c_SurfaceAlphaList extends c_List2{
	public function m_SurfaceAlphaList_new():c_SurfaceAlphaList{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<803>";
		super.m_List_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/trender.monkey<803>";
		popErr();
		return this;
	}
}
class c_ArrayIntMap extends Object{
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_ArrayIntMap_new():c_ArrayIntMap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<8>";
		m_data=new_object_array(32);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<9>";
		m_length=31;
		popErr();
		return this;
	}
	public function p_Set3(t_id:int,t_obj:VertexBuffer3D):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<26>";
		while(t_id>=m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<27>";
			m_length=m_length+32;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<28>";
			m_data=resize_object_array(m_data,m_length+1);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<30>";
		dbg_array(m_data,t_id)[dbg_index]=t_obj;
		popErr();
	}
	public function p_Get2(t_id:int):VertexBuffer3D{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
		if(t_id<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
			popErr();
			return dbg_array(m_data,t_id)[dbg_index];
		}
		popErr();
		return null;
	}
}
class c_ArrayIntMap2 extends Object{
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_ArrayIntMap_new():c_ArrayIntMap2{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<8>";
		m_data=new_object_array(32);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<9>";
		m_length=31;
		popErr();
		return this;
	}
	public function p_Set4(t_id:int,t_obj:IndexBuffer3D):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<26>";
		while(t_id>=m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<27>";
			m_length=m_length+32;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<28>";
			m_data=resize_object_array(m_data,m_length+1);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<30>";
		dbg_array(m_data,t_id)[dbg_index]=t_obj;
		popErr();
	}
	public function p_Get2(t_id:int):IndexBuffer3D{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
		if(t_id<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
			popErr();
			return dbg_array(m_data,t_id)[dbg_index];
		}
		popErr();
		return null;
	}
}
class c_TexData extends Object{
	public function m_TexData_new():c_TexData{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<51>";
		popErr();
		return this;
	}
	internal var m_tex_count:int=0;
	internal var m_texture:Array=new_object_array(8);
	internal var m_tex_flags:Array=new_number_array(8);
	internal var m_tex_blend:Array=new_number_array(8);
	internal var m_tex_coords:Array=new_number_array(8);
	internal var m_tex_u_scale:Array=new_number_array(8);
	internal var m_tex_v_scale:Array=new_number_array(8);
	internal var m_tex_u_pos:Array=new_number_array(8);
	internal var m_tex_v_pos:Array=new_number_array(8);
	internal var m_tex_ang:Array=new_number_array(8);
	internal var m_tex_cube_mode:Array=new_number_array(8);
	internal var m_frame:Array=new_number_array(8);
	internal var m_tex_smooth:Array=new_number_array(8);
	internal var m_uv_clamp:int=0;
	internal static var m_null_tex:c_TTexture;
	public function p_UpdateTexture(t_surf:c_TSurface,t_ent:c_TEntity):int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<74>";
		m_tex_count=0;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<76>";
		m_tex_count=dbg_object(dbg_object(t_ent).m_brush).m_no_texs;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<78>";
		if(dbg_object(dbg_object(t_surf).m_brush).m_no_texs>m_tex_count){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<78>";
			m_tex_count=dbg_object(dbg_object(t_surf).m_brush).m_no_texs;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<83>";
		for(var t_ix:int=0;t_ix<=m_tex_count-1;t_ix=t_ix+1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<85>";
			if(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]!=null || dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<91>";
				if(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]!=null){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<92>";
					if(dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_width==0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<92>";
						m_tex_count=0;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<92>";
						break;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<94>";
					dbg_array(m_texture,t_ix)[dbg_index]=dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index];
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<95>";
					dbg_array(m_tex_flags,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_flags;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<96>";
					dbg_array(m_tex_blend,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_blend;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<97>";
					dbg_array(m_tex_coords,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_coords;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<98>";
					dbg_array(m_tex_u_scale,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_u_scale;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<99>";
					dbg_array(m_tex_v_scale,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_v_scale;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<100>";
					dbg_array(m_tex_u_pos,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_u_pos;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<101>";
					dbg_array(m_tex_v_pos,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_v_pos;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<102>";
					dbg_array(m_tex_ang,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_angle;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<103>";
					dbg_array(m_tex_cube_mode,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_cube_mode;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<104>";
					dbg_array(m_frame,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_tex_frame;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<105>";
					dbg_array(m_tex_smooth,t_ix)[dbg_index]=((dbg_object(dbg_array(dbg_object(dbg_object(t_ent).m_brush).m_tex,t_ix)[dbg_index]).m_tex_smooth)?1:0);
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<107>";
					if(dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_width==0){
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<107>";
						m_tex_count=t_ix-1;
						_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<107>";
						break;
					}
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<109>";
					dbg_array(m_texture,t_ix)[dbg_index]=dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index];
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<110>";
					dbg_array(m_tex_flags,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_flags;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<111>";
					dbg_array(m_tex_blend,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_blend;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<112>";
					dbg_array(m_tex_coords,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_coords;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<113>";
					dbg_array(m_tex_u_scale,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_u_scale;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<114>";
					dbg_array(m_tex_v_scale,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_v_scale;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<115>";
					dbg_array(m_tex_u_pos,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_u_pos;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<116>";
					dbg_array(m_tex_v_pos,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_v_pos;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<117>";
					dbg_array(m_tex_ang,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_angle;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<118>";
					dbg_array(m_tex_cube_mode,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_cube_mode;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<119>";
					dbg_array(m_frame,t_ix)[dbg_index]=dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_tex_frame;
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<120>";
					dbg_array(m_tex_smooth,t_ix)[dbg_index]=((dbg_object(dbg_array(dbg_object(dbg_object(t_surf).m_brush).m_tex,t_ix)[dbg_index]).m_tex_smooth)?1:0);
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<123>";
				if((dbg_array(m_tex_flags,t_ix)[dbg_index]&16)!=0 || (dbg_array(m_tex_flags,t_ix)[dbg_index]&32)!=0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<124>";
					m_uv_clamp=1;
				}else{
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<126>";
					m_uv_clamp=0;
				}
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<129>";
				if(dbg_object(dbg_array(m_texture,t_ix)[dbg_index]).m_width==0){
					_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<129>";
					dbg_array(m_texture,t_ix)[dbg_index]=m_null_tex;
				}
			}
		}
		popErr();
		return 0;
	}
}
class c_ArrayIntMap3 extends Object{
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_ArrayIntMap_new():c_ArrayIntMap3{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<8>";
		m_data=new_object_array(32);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<9>";
		m_length=31;
		popErr();
		return this;
	}
	public function p_Get2(t_id:int):Texture{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
		if(t_id<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
			popErr();
			return dbg_array(m_data,t_id)[dbg_index];
		}
		popErr();
		return null;
	}
	public function p_Set5(t_id:int,t_obj:Texture):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<26>";
		while(t_id>=m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<27>";
			m_length=m_length+32;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<28>";
			m_data=resize_object_array(m_data,m_length+1);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<30>";
		dbg_array(m_data,t_id)[dbg_index]=t_obj;
		popErr();
	}
}
internal function bb_flash11_AGALMatrix(t_m:c_Matrix):Array{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/flash11.monkey<1261>";
	var t_:Array=[dbg_array(dbg_array(dbg_object(t_m).m_grid,0)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,1)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,2)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,3)[dbg_index],0)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,0)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,1)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,2)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,3)[dbg_index],1)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,0)[dbg_index],2)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,1)[dbg_index],2)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,2)[dbg_index],2)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,3)[dbg_index],2)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,0)[dbg_index],3)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,1)[dbg_index],3)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,2)[dbg_index],3)[dbg_index],dbg_array(dbg_array(dbg_object(t_m).m_grid,3)[dbg_index],3)[dbg_index]];
	popErr();
	return t_;
}
class c_TPixmapFlash extends c_TPixmap implements c_IPixmapManager{
	public function m_TPixmapFlash_new():c_TPixmapFlash{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<45>";
		super.m_TPixmap_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<45>";
		popErr();
		return this;
	}
	public static function m_Init():int{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<58>";
		if(!((c_TPixmap.m_manager)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<58>";
			c_TPixmap.m_manager=((new c_TPixmapFlash).m_TPixmapFlash_new());
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<59>";
		if(!((c_TPixmap.m_preloader)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<59>";
			c_TPixmap.m_preloader=(new c_TPixmapPreloader).m_TPixmapPreloader_new((new c_PreloadFlash).m_PreloadFlash_new());
		}
		popErr();
		return 0;
	}
	internal var m_pixels:TPixmap=null;
	public override function p_ResizePixmap(t_neww:int,t_newh:int):c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<106>";
		var t_newpix:c_TPixmapFlash=(new c_TPixmapFlash).m_TPixmapFlash_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<107>";
		if(t_neww<1 || t_newh<1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<107>";
			var t_:c_TPixmap=(t_newpix);
			popErr();
			return t_;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<109>";
		dbg_object(t_newpix).m_pixels=TPixmap.ResizePixmap(m_pixels,t_neww,t_newh,true);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<110>";
		dbg_object(t_newpix).m_width=t_neww;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<111>";
		dbg_object(t_newpix).m_height=t_newh;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<113>";
		var t_2:c_TPixmap=(t_newpix);
		popErr();
		return t_2;
	}
	public override function p_ResizePixmapNoSmooth(t_neww:int,t_newh:int):c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<119>";
		var t_newpix:c_TPixmapFlash=(new c_TPixmapFlash).m_TPixmapFlash_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<120>";
		if(t_neww<1 || t_newh<1){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<120>";
			var t_:c_TPixmap=(t_newpix);
			popErr();
			return t_;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<122>";
		dbg_object(t_newpix).m_pixels=TPixmap.ResizePixmap(m_pixels,t_neww,t_newh,false);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<123>";
		dbg_object(t_newpix).m_width=t_neww;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<124>";
		dbg_object(t_newpix).m_height=t_newh;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<126>";
		var t_2:c_TPixmap=(t_newpix);
		popErr();
		return t_2;
	}
	internal var m_format:int=0;
	internal var m_pitch:int=0;
	public function p_LoadPixmap(t_f:String):c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<75>";
		var t_p:c_TPixmapFlash=(new c_TPixmapFlash).m_TPixmapFlash_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<77>";
		var t_info:Array=new_number_array(3);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<79>";
		c_TPixmap.m_preloader.p_GetPixmapPreLoad((t_p),t_f);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<81>";
		dbg_object(t_p).m_format=4;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<83>";
		if((dbg_object(t_p).m_width)!=0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<83>";
			dbg_object(t_p).m_pitch=dbg_object(t_p).m_width;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<85>";
		if(dbg_object(t_p).m_width==0 || dbg_object(t_p).m_height==0 || !((dbg_object(t_p).m_pixels)!=null)){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<85>";
			bb_tutility_Dprint("Image Not Preloaded: "+t_f,"","","","","");
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<87>";
		var t_:c_TPixmap=(t_p);
		popErr();
		return t_;
	}
	public function p_CreatePixmap(t_w:int,t_h:int,t_format:int):c_TPixmap{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<93>";
		var t_p:c_TPixmapFlash=(new c_TPixmapFlash).m_TPixmapFlash_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<95>";
		dbg_object(t_p).m_pixels=TPixmap.CreatePixmap(t_w,t_h);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<96>";
		dbg_object(t_p).m_width=t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<97>";
		dbg_object(t_p).m_height=t_h;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<98>";
		dbg_object(t_p).m_format=t_format;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<99>";
		dbg_object(t_p).m_pitch=t_w;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<101>";
		var t_:c_TPixmap=(t_p);
		popErr();
		return t_;
	}
	public override function p_MaskPixmap(t_r:int,t_g:int,t_b:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<147>";
		m_pixels=TPixmap.MaskPixmap(m_pixels,0xff000000|t_r<<16|t_b<<8|t_g);
		popErr();
	}
	public override function p_FreePixmap():void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<173>";
		m_pixels=null;
		popErr();
	}
}
class c_PreloadFlash extends Object implements c_IPreloadManager{
	public function m_PreloadFlash_new():c_PreloadFlash{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<185>";
		popErr();
		return this;
	}
	internal var m_p_map:c_ArrayIntMap4=(new c_ArrayIntMap4).m_ArrayIntMap_new();
	public function p_IsLoaded(t_file_id:int):Boolean{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<191>";
		var t_f:c_PreloadData=m_p_map.p_Get2(t_file_id);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<192>";
		if((t_f)!=null){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<192>";
			var t_:Boolean=TPixmap.CheckIsLoaded(dbg_object(t_f).m_data);
			popErr();
			return t_;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<194>";
		popErr();
		return false;
	}
	public function p_PreLoadData(t_f:String,t_id:int):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<202>";
		if(t_id<1){
			popErr();
			return;
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<204>";
		t_f=bb_data_FixDataPath(t_f);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<205>";
		t_f=string_replace(t_f,"monkey://","");
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<207>";
		var t_d:c_PreloadData=(new c_PreloadData).m_PreloadData_new();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<208>";
		dbg_object(t_d).m_id=t_id;
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<209>";
		dbg_object(t_d).m_data=TPixmap.LoadImageData(t_f);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<211>";
		m_p_map.p_Set6(t_id,t_d);
		popErr();
	}
	public function p_SetPixmapFromID(t_pixmap:c_TPixmap,t_id:int,t_f:String):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<217>";
		var t_p:c_TPixmapFlash=((t_pixmap) as c_TPixmapFlash);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<218>";
		if(((t_p)!=null) && t_id>0){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<220>";
			var t_d:c_PreloadData=m_p_map.p_Get2(t_id);
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<222>";
			if((t_d)!=null){
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<225>";
				dbg_object(t_p).m_pixels=dbg_object(t_d).m_data;
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<226>";
				var t_info:Array=TPixmap.GetInfo(dbg_object(t_p).m_pixels);
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<227>";
				dbg_object(t_p).m_width=dbg_array(t_info,0)[dbg_index];
				_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<228>";
				dbg_object(t_p).m_height=dbg_array(t_info,1)[dbg_index];
			}
		}
		popErr();
	}
}
internal function bb_functions_CreateTexture(t_width:int,t_height:int,t_flags:int,t_frames:int):c_TTexture{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<524>";
	var t_:c_TTexture=c_TTexture.m_CreateTexture(t_width,t_height,t_flags,t_frames,null);
	popErr();
	return t_;
}
internal function bb_functions_CreateSprite(t_parent:c_TEntity):c_TSprite{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/functions.monkey<495>";
	var t_:c_TSprite=c_TSprite.m_CreateSprite(t_parent);
	popErr();
	return t_;
}
internal function bb_mojographics_Transform2D(t_mat:c_Matrix,t_x:Number,t_y:Number,t_z:Number):Array{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<494>";
	var t_t2d:Array=new_number_array(3);
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<495>";
	dbg_array(t_t2d,0)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],0)[dbg_index]*t_x+dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],0)[dbg_index]*t_y+dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],0)[dbg_index];
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<496>";
	dbg_array(t_t2d,1)[dbg_index]=dbg_array(dbg_array(dbg_object(t_mat).m_grid,0)[dbg_index],1)[dbg_index]*t_x+dbg_array(dbg_array(dbg_object(t_mat).m_grid,1)[dbg_index],1)[dbg_index]*t_y+dbg_array(dbg_array(dbg_object(t_mat).m_grid,3)[dbg_index],1)[dbg_index];
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<497>";
	dbg_array(t_t2d,2)[dbg_index]=t_z;
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/mojographics.monkey<498>";
	popErr();
	return t_t2d;
}
internal function bb_tutility_Dprint(t_x:String,t_y:String,t_z:String,t_a:String,t_b:String,t_c:String):int{
	pushErr();
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/tutility.monkey<14>";
	var t_st:String=t_x+" "+t_y+" "+t_z+" "+t_a+" "+t_b+" "+t_c;
	_errInfo="C:/MonkeyXPro77f/modules/minib3d/tutility.monkey<15>";
	print(t_st);
	popErr();
	return 0;
}
class c_PreloadData extends Object{
	internal var m_data:TPixmap=null;
	public function m_PreloadData_new():c_PreloadData{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/flash11/tpixmap_flash.monkey<179>";
		popErr();
		return this;
	}
	internal var m_id:int=0;
}
class c_ArrayIntMap4 extends Object{
	internal var m_data:Array=[];
	internal var m_length:int=0;
	public function m_ArrayIntMap_new():c_ArrayIntMap4{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<8>";
		m_data=new_object_array(32);
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<9>";
		m_length=31;
		popErr();
		return this;
	}
	public function p_Get2(t_id:int):c_PreloadData{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
		if(t_id<m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<22>";
			popErr();
			return dbg_array(m_data,t_id)[dbg_index];
		}
		popErr();
		return null;
	}
	public function p_Set6(t_id:int,t_obj:c_PreloadData):void{
		pushErr();
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<26>";
		while(t_id>=m_length){
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<27>";
			m_length=m_length+32;
			_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<28>";
			m_data=resize_object_array(m_data,m_length+1);
		}
		_errInfo="C:/MonkeyXPro77f/modules/minib3d/math/arrayintmap.monkey<30>";
		dbg_array(m_data,t_id)[dbg_index]=t_obj;
		popErr();
	}
}
function bbInit():void{
	bb_app__app=null;
	bb_app__delegate=null;
	bb_app__game=BBGame.Game();
	bb_graphics_device=null;
	bb_graphics_context=(new c_GraphicsContext).m_GraphicsContext_new();
	c_Image.m_DefaultFlags=0;
	bb_audio_device=null;
	bb_input_device=null;
	bb_app__devWidth=0;
	bb_app__devHeight=0;
	bb_app__displayModes=[];
	bb_app__desktopMode=null;
	bb_graphics_renderDevice=null;
	c_TRender.m_shader2D=((new c_BlankShader).m_BlankShader_new());
	c_TRender.m_render=null;
	c_MojoEmulationDevice.m__device=null;
	c_MojoEmulationDevice.m__olddevice=null;
	c_MojoEmulationDevice.m__quadCache=null;
	c_FlashMiniB3D.m_driver=(new Driver3D);
	c_TEntity.m_entity_list=(new c_EntityList).m_EntityList_new();
	c_TTexture.m_useGlobalResizeSmooth=true;
	c_TRender.m_draw_list=(new c_List3).m_List_new();
	c_MojoEmulationDevice.m_firstTimeRun=false;
	c_TPixmap.m_preloader=null;
	c_Stack2.m_NIL=null;
	bb_app__updateRate=0;
	c_TRender.m_width=0;
	c_TRender.m_height=0;
	c_TCamera.m_cam_list=(new c_EntityList2).m_EntityList_new();
	c_TEntity.m_temp_mat=(new c_Matrix).m_Matrix_new();
	c_TBone.m_t_mat=(new c_Matrix).m_Matrix_new();
	c_TBone.m_new_mat=(new c_Matrix).m_Matrix_new();
	c_TLight.m_no_lights=0;
	c_TLight.m_max_lights=8;
	c_TLight.m_light_list=(new c_List5).m_List_new();
	c_ShortBuffer.m_i2f=null;
	c_TPixmap.m_manager=null;
	c_TText.m_mask_color=0;
	c_TTextureFilter.m_filter_list=(new c_List8).m_List_new();
	c_TTexture.m_tex_list=(new c_List9).m_List_new();
	c_TTexture.m_tex_bind_stack=(new c_TextureStack).m_TextureStack_new();
	c_CollisionInfo.m_t_mat=null;
	c_CollisionInfo.m_col_info=(new c_CollisionInfo).m_CollisionInfo_new();
	c_TCollisionPair.m_ent_lists=new_object_array(100);
	c_CollisionInfo.m_starttime=.0;
	c_TCollisionPair.m_list=(new c_List10).m_List_new();
	c_CollisionInfo.m_nullVec=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	c_Vec3.m_temp=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	c_CollisionInfo.m_t_vec=(new c_Vector).m_Vector_new(0.0,0.0,0.0);
	c_MeshCollider.m_ray_line=(new c_Line).m_Line_new();
	c_Stack4.m_NIL=null;
	c_CollisionObject.m_BOXQUADS=[2,3,1,0,3,7,5,1,7,6,4,5,6,2,0,4,6,7,3,2,0,1,5,4];
	c_TRender.m_tris_rendered=0;
	c_Stack3.m_NIL=null;
	c_TShader.m_process_list=(new c_List13).m_List_new();
	c_TShader.m_g_shader=null;
	c_TRender.m_render_list=(new c_RenderAlphaList).m_RenderAlphaList_new();
	c_TRender.m_render_alpha_list=(new c_RenderAlphaList).m_RenderAlphaList_new();
	c_TRender.m_wireframe=0;
	c_TRender.m_temp_shader=null;
	c_TRender.m_alpha_pass=0;
	c_TRender.m_camera2D=(new c_TCamera).m_TCamera_new();
	c_TShaderFlash.m_driver=null;
	c_TShaderFlash.m_g_id=0;
	c_MultiShader.m_init=false;
	c_FullBrightOneTexShader.m_VP="m44 vt1, va0, vc0\nmov v0, va1\nmov v1, va2\nmov vt0, va3\nmov vt0, vc4\nmov vt0, vc8\nmax vt3, vc18.xxxx, va1.xyzw\nmul v0, vc16, vt3\nmov v0.w, vt3.w\nadd vt0.x, vc23.x, va2.x\nmul vt0.x, vc23.z, vt0.x\nadd vt0.y, va2.y, vc23.y\nmul vt0.y, vc23.w, vt0.y\nsub vt0.x, vt0.x, vt0.y\nmul v1.x, vc24.x, vt0.x\nadd vt0.x, vc23.x, va2.x\nmul vt0.x, vc23.w, vt0.x\nadd vt0.y, va2.y, vc23.y\nmul vt0.y, vc23.z, vt0.y\nadd vt0.x, vt0.x, vt0.y\nmul v1.y, vc24.y, vt0.x\nmov op, vt1\n\n";
	c_FullBrightOneTexShader.m_FP="tex ft1, v1, fs0 <2d,TEXTURE_WRAP,linear>\nmov ft2, v0\nmul ft2, ft1, ft2\nALPHATESTmov oc, ft2\n";
	c_OneLightOneTexShader.m_VP="m44 vt1, va0, vc0\nmov v0, va1\nmov v1, va2\nm44 vt3, va3.xyz, vc8\nnrm vt3.xyz, vt3.xyz\nmov vt4.x, vc12.w\nmov vt4.y, vc13.w\nmov vt4.z, vc14.w\nm44 vt0, va0, vc4\nsub vt0, vt4.xyz, vt0.xyz\nm44 vt7, vt4.xyz, vc12\ndp3 vt5, vt0.xyz, vt0.xyz\nsqt vt5,vt5\nmul vt6.x, vc27.y, vt5\nadd vt6.x, vc27.x, vt6.x\nrcp vt6.x,vt6.x\nmov vt5.x, vc26.y\nadd vt5.x, vt5.x, vc26.z\nmul vt6.x, vt6.x, vt5.x\nmov vt5.x, vc26.x\nsge vt5.x, vt5.x, vc26.y\nadd vt6.x, vt6.x, vt5.x\nmul vt7, vt7, vc26.xxxx\nmul vt0, vt0, vc26.yyyy\nadd vt0, vt7, vt0\ndp3 vt0.xyz, vt0.xyz, vt3.xyz\nmul vt0.xyz, vt0.xyz, vt6.xxx\nsat vt0.xyz, vt0.xyz\nmax vt0.xyz, vt0.xyz, vc17.xyz\nmax vt3, vc18.xxxx, va1.xyzw\nmul vt3, vc16.xyzw, vt3.xyzw\nmul vt3.xyz, vt3.xyz, vc22.xyz\nmul v0, vt3.xyz, vt0.xyz\nmov v0.w, vt3.w\nmov op, vt1\n\n";
	c_OneLightOneTexShader.m_FP="tex ft1, v1, fs0 <2d,TEXTURE_WRAP,linear>\nALPHATESTmul ft2, ft1, v0\nmov oc, ft2\n";
	c_OneLightOneTexShader.m_alphaTest="sub ft3.x ft1.w fc25.x\nkil ft3.x\n";
	c_FullBrightOneTexShader.m_alphaTest="sub ft3.x ft1.w fc25.x\nkil ft3.x\n";
	c_TShader.m_default_shader=null;
	c_FlashMiniB3D.m_last_texture=null;
	c_FlashMiniB3D.m_last_sprite=null;
	c_FlashMiniB3D.m_current_cam=null;
	c_FlashMiniB3D.m_alpha_list=(new c_SurfaceAlphaList).m_SurfaceAlphaList_new();
	c_TLight.m_ambient_red=0.1;
	c_TLight.m_ambient_green=0.1;
	c_TLight.m_ambient_blue=0.1;
	c_TexData.m_null_tex=null;
	c_FlashMiniB3D.m_last_tex_count=8;
	c_FlashMiniB3D.m_null_tex=null;
	c_FlashMiniB3D.m_temp_cam=(new c_Matrix).m_Matrix_new();
	c_FlashMiniB3D.m_temp_mat=(new c_Matrix).m_Matrix_new();
	c_Matrix.m_temp=(new c_Matrix).m_Matrix_new();
	c_TRender.m_vbo_enabled=false;
	c_TEntity.m_global_mat=(new c_Matrix).m_Matrix_new();
	c_FlashMiniB3D.m_fastQuad=null;
	c_FlashMiniB3D.m_shader2d_=null;
	c_MojoSurface.m_list=new_string_array(0);
	c_MojoSurface.m_isLoading=false;
	c_TSprite.m_temp_mat=(new c_Matrix).m_Matrix_new();
}
//${TRANSCODE_END}
